On 7 November 2014 03:05, Dave Castellano <
li...@ruby-forum.com> wrote:
> Hi,
>
> I'm stuck trying to figure out how to do a query to find all the
> questions in a selected subject only.
>
> My associations:
>
> class Subject < ActiveRecord::Base
> has_many :books
> has_many :questions
> has_many :chapters, :through => :books
> has_many :sections, :through => :chapters
> has_many :subsections, :through => :sections
> has_many :minisections, :through => :subsections
>
> class Question < ActiveRecord::Base
> has_and_belongs_to_many :minisections
>
> The query:
> @question_list = Question.where(all the questions associated with the
> subject through the above associations???)
need question belongs_to subject. Also you need to re-think your