I like the idea, but this is what I get:
@answers = @company.surveys.survey_questions.survey_answers undefined method `survey_questions' for #<Class:0x203b590> I feel like the first call, @company.surveys is just returning an array and then I'm trying to call the survey_questions method on that array. Is there a way to modify that call to get the desired chaining? On Mar 5, 1:13 am, Peter Vandenabeele <[email protected]> wrote: > On Thu, Mar 5, 2009 at 9:21 AM, Chad <[email protected]> wrote: > > In the following model, is there an easy way to setup my models so > > that I can make the following call: @company.survey_answers > > > class Company < ActiveRecord::Base > > has_many :surveys > > has_many :survey_questions, :through => :surveys > > end > > > class Surveys ... > > belongs_to :company > > has_many :survey_questions > > end > > > class SurveyQuestions ... > > belongs_to :survey > > has_many :survey_answers > > end > > > class SurveyAnswers ... > > belongs_to :survey_question > > end > > What happens when you try: > > (1) @company.surveys.survey_questions.survey_answers > > or > > (2) @company.survey_questions.survey_answers > > I believe form (1) should certainly work after removing the line > 'has_many :survey_questions, :through => :surveys' > > I am uncertain if form (2) will work (because I am uncertain if > has_many :through works that way and no > time to test it here) > > I don't see how '[email protected]_answers' could work since there is no > has_many > relationship with the name 'survey_answers' in the Company class. It > is only defined > in the SurveyQuestions class. > > HTH, > > Peter --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---

