Forum: Ruby on Rails Join table query question

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Be2b7277cff8516117cbd7a33df7b03a?d=identicon&s=25 Dave Castellano (dcastellano1)
on 2013-08-15 20:53
Hi,

I created a join table and am having trouble figuring out how to query
it...

create_table "minisections_questions", :id => false, :force => true do
|t|
    t.integer "minisection_id"
    t.integer "question_id"
  end

I am trying to find all question id's with a specific minisection_id  eg
(params[:minisection_id])

@question_list = ???

ANy guidance would be helpful as I really am having trouble figuring
this out.

Thanks
Dave
622547b2f551885f92449b4924573242?d=identicon&s=25 John Davalos (Guest)
on 2013-08-15 21:06
(Received via mailing list)
could you do something like
Minisection.find(params[:minisection_id]).questions

@question_list = Minisection.find(params[:minisection_id]).questions
Be2b7277cff8516117cbd7a33df7b03a?d=identicon&s=25 Dave Castellano (dcastellano1)
on 2013-08-15 21:42
Dave Castellano wrote in post #1118800:
> Hi,
>
> I created a join table and am having trouble figuring out how to query
> it...
>


Thank you!

Dave
622547b2f551885f92449b4924573242?d=identicon&s=25 John Davalos (Guest)
on 2013-08-15 23:32
(Received via mailing list)
worked? if so, you're welcome!
Be2b7277cff8516117cbd7a33df7b03a?d=identicon&s=25 Dave Castellano (dcastellano1)
on 2013-08-16 03:29
John Davalos wrote in post #1118812:
> worked? if so, you're welcome!

Yep!  Worked well, and helped me understand the concept.  so thanks...
622547b2f551885f92449b4924573242?d=identicon&s=25 John Davalos (Guest)
on 2013-08-20 00:48
(Received via mailing list)
awesome! no problem.
This topic is locked and can not be replied to.