[Rails] Re: Select and inner join
Colin Law wrote in post #1097096:
>> Paragraph.joins(:course_paragraphs => :course)
>> .where('course_paragraphs.course_id' => @course.id)
>
> You don't need to do that. If you have a course in @course then its
> paragraphs are just @course.paragraphs. It is rare to have to use
> joins when working with Rails if you have got the associations right.
You're right. I tried to resolve my problem in a different way and I'm
returned unintentionaly at the classic method with a long solution :)
> I think this should work.
> @course.paragraphs.select( :id )
Unfortunately it gave the same problem.
(:id) -> MySQL error
(:paragraphs => :id) -> hexadecimal values
I took the decision to keep the "hexadecimal" solution and adapt another
bit of my code to have same values.
In any case, thanks for the answer.
--
Posted via http://www.ruby-forum.com/.
--
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-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home