Created
January 8, 2016 20:18
-
-
Save brycesenz/e96cf0fe5d83a130a305 to your computer and use it in GitHub Desktop.
Salaries
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class PayStub | |
belongs_to :salary | |
attr_accessor :start_date, :end_date | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Salary | |
belongs_to :user | |
has_many :pay_stubs | |
def historic_pay_stubs(to_date, end_date) | |
pay_stubs.select do |stub| | |
stub.start_date >= to_date && stub.end_date <= end_date | |
end | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class User | |
has_many :salaries | |
has_many :pay_stubs, through: :salaries | |
def historic_pay_stubs(to_date, end_date) | |
pay_stubs.select do |stub| | |
stub.start_date >= to_date && stub.end_date <= end_date | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment