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 '@company.survey_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 -~----------~----~----~----~------~----~------~--~---

