Jump to content

The ultimate community for Ruby on Rails developers.


Photo

Activerecord, Join, Select *

activerecord join select

  • Please log in to reply
1 reply to this topic

#1 GLaD0S

GLaD0S

    Passenger

  • Members
  • 6 posts

Posted 10 April 2014 - 10:26 PM

After much searching I have been unable to find the correct information on selecting * between a table join.

 

Here is the query I am dealing with:

 

Assignment.joins("LEFT JOIN courses ON courses.id = assignments.context_id LEFT JOIN enrollments ON enrollments.course_id = courses.id").includes(:courses).where(:enrollments => {:user_id => '8', :course_id => '1', :workflow_state => 'active'})

 

And I would like to select, assignments.* and courses.*, but joins only selects assignments.*

 

Any help on this issue would be greatly appreciated. I feel like I am missing something simple



#2 th3mus1cman

th3mus1cman

    Signalman

  • Members
  • 14 posts
  • LocationRichmond, VA

Posted 04 June 2014 - 05:43 PM

Can you post the result of this to the forum?

Assignment.joins("LEFT JOIN courses ON courses.id = assignments.context_id LEFT JOIN enrollments ON enrollments.course_id = courses.id").includes(:courses).where(:enrollments => {:user_id => '8', :course_id => '1', :workflow_state => 'active'}).to_sql

Rails Developer and Partner at Left + Right






Also tagged with one or more of these keywords: activerecord, join, select

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users