I have two models named Customer and Order.
Customer < ActiveRecord::Base
Order < ActiveRecord::Base
Customer model has attributes like first_name and last_name. Order has
customer_id along with other attributes.
Now, I want Customer first_name for specific order. I can get it with
Customer.joins(:orders).where('orders.id = 1').select('first_name').
But, how to get it along with attributes of order table also. Say, I want
both customers first_name and orders table created_at value.
When I try,
this returns only order table records. What is the best way to select
attributes of joined tables also with Active Record Query.
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to email@example.com.
To unsubscribe from this group, send email to firstname.lastname@example.org.
To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/ueZg0GTIwiUJ.
For more options, visit https://groups.google.com/groups/opt_out.