Join table query question

28 views
Skip to first unread message

Dave Castellano

unread,
Aug 15, 2013, 2:53:27 PM8/15/13
to rubyonra...@googlegroups.com
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

--
Posted via http://www.ruby-forum.com/.

John Davalos

unread,
Aug 15, 2013, 3:05:40 PM8/15/13
to rubyonra...@googlegroups.com
could you do something like Minisection.find(params[:minisection_id]).questions

@question_list = Minisection.find(params[:minisection_id]).questions


--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-ta...@googlegroups.com.
To post to this group, send email to rubyonra...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/513c24195c2f024833fc060312e55fd4%40ruby-forum.com.
For more options, visit https://groups.google.com/groups/opt_out.

Dave Castellano

unread,
Aug 15, 2013, 3:42:25 PM8/15/13
to rubyonra...@googlegroups.com
Dave Castellano wrote in post #1118800:
> Hi,
>
> I created a join table and am having trouble figuring out how to query
> it...
>


Thank you!

John Davalos

unread,
Aug 15, 2013, 5:30:37 PM8/15/13
to rubyonra...@googlegroups.com
worked? if so, you're welcome!


--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-ta...@googlegroups.com.
To post to this group, send email to rubyonra...@googlegroups.com.

Dave Castellano

unread,
Aug 15, 2013, 9:29:59 PM8/15/13
to rubyonra...@googlegroups.com
John Davalos wrote in post #1118812:
> worked? if so, you're welcome!

Yep! Worked well, and helped me understand the concept. so thanks...

John Davalos

unread,
Aug 19, 2013, 6:47:00 PM8/19/13
to rubyonra...@googlegroups.com
awesome! no problem.


--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-ta...@googlegroups.com.
To post to this group, send email to rubyonra...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages