Skip to content

Instantly share code, notes, and snippets.

@nz
Created November 18, 2008 18:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nz/26191 to your computer and use it in GitHub Desktop.
Save nz/26191 to your computer and use it in GitHub Desktop.
class GatheringPlan < ActiveRecord::Base
belongs_to :roov
belongs_to :gathering_idea
has_many :participations, :class_name => "GatheringPlanParticipation"
has_many :participants, :through => :participations, :source => :user
has_many :votes, :class_name => "GatheringPlanVote"
has_many :suggestions, :through => :votes, :source => :suggestion
end
class GatheringPlanParticipation < ActiveRecord::Base
belongs_to :user
belongs_to :gathering_plan
has_many :suggestions, :class_name => "GatheringPlanSuggestion"
has_many :votes, :class_name => "GatheringPlanVote"
has_many :voted_suggestions, :through => :votes, :source => :suggestion
def user_voted_for?(suggestion)
voted_suggestions.include?(suggestion)
end
end
class GatheringPlanSuggestion < ActiveRecord::Base
belongs_to :user
belongs_to :plan, :class_name => "GatheringPlan"
# t.datetime :time
# t.string :place_name
end
class GatheringPlanVote < ActiveRecord::Base
belongs_to :user
belongs_to :gathering_plan
belongs_to :suggestion, :class_name => "GatheringPlanSuggestion"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment