On Feb 17, 1:00 pm, markds75 <[email protected]> wrote:
> Okay, well here's the real code I'm dealing with (sorry if its long).
> I'm adding surveys to a research project I've been working on, So I've
> got three migration files, one to create the surveys, one to create
> the survey questions, and another to create the possible survey
> answers.
[snip]
> And I've got 3 models to go with the new classes.
>
> survey.rb:
>
> class Survey < ActiveRecord::Base
>   has_many :survey_questions, :order => :position
> end
>
> survey_questions.rb:
>
> class SurveyQuestions < ActiveRecord::Base
>   belongs_to :survey
>   acts_as_list :scope => :survey
>
>   has_many :survey_possible_answers
> end
>
> survey_possible_answers.rb:
>
> class SurveyPossibleAnswers < ActiveRecord::Base
>   belongs_to :survey_questions, :order => :position
>   acts_as_list :scope => :survey_questions
> end

The problem: the belongs_to here is going to fail. In the vast
majority of cases,
belongs_to should have a singular name. The code here won't ever work,
as you've
got the DB field (survey_question_id) named correctly, and it won't
match.

BTW, tiny typos like this are why I prefer to start by poking at the
models in console;
frequently, that will drive the first tests of the models, and if
you've got a typo it will
be very apparent...

--Matt Jones


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to