Created
September 28, 2011 00:43
-
-
Save SoldierCoder/1246686 to your computer and use it in GitHub Desktop.
models and a controller question
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
Ok, users should get a list of campaigns (to add or withdraw support | |
to/from whether or not they support it now. But I also want to to | |
show if they are supporting it. | |
CampaignSupporters will hold information about which users | |
currently support which campaigns. But how do i get list | |
of all campaigns so logged in user can choose which they'd | |
like to support? | |
class Campaign < ActiveRecord::Base | |
has_many :campaign_supporters | |
has_many :users, :through => :campaign_supporters | |
end | |
class User < ActiveRecord::Base | |
has_many :campaign_supporters | |
has_many :campaigns, :through => :campaign_supporters | |
end | |
class CampaignSupporter < ActiveRecord::Base | |
belongs_to :campaign | |
belongs_to :user | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment