Created
December 14, 2014 03:59
-
-
Save c-lliope/6313e88011d1c26d4610 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 PlantBucketAssignment | |
belongs_to :plant | |
belongs_to :bucket | |
end | |
class Bucket | |
has_many :plant_bucket_assignments | |
has_many :plants, through: :plant_bucket_assignments | |
def current_plant | |
plant.sort_by(:created_at).last | |
end | |
end | |
class Plant | |
has_many :plant_bucket_assignments | |
has_many :buckets, through: :plant_bucket_assignments | |
def current_bucket | |
buckets.sort_by(:created_at).last | |
end | |
def current_bucket=(bucket) | |
buckets << bucket | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment