Created
December 26, 2013 13:26
-
-
Save tacettin/8133819 to your computer and use it in GitHub Desktop.
First of all in has_many class name should be in plural: has_many :choices
And you should add attr_accessible poll_id or choice_ids for Model from which you want to edit this association. Or just delete all attr_accessible for first try.
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 Poll < ActiveRecord::Base | |
attr_accessible :published, :title, choice_ids | |
validates :published, :presence => true | |
validates :title, :presence => true, :length => { :minimum => 10 } | |
has_many :choices, :dependent => :destroy | |
end | |
class Choice < ActiveRecord::Base | |
belongs_to :poll | |
attr_accessible :choice_text, :votes, :poll_id | |
validates :choice_text, :presence => true | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment