B
B
Bogdan2017-05-01 22:11:25
Ruby on Rails
Bogdan, 2017-05-01 22:11:25

How to set child table names in joins() in Rails?

Hello. Is it possible to somehow use pure Rails for order and select, without using string values ​​and the name of the table and field?

@in.institution_order_products.joins( product: [:products_type] )
  .select('products.name').order('products_types.priority')

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Leonchik, 2017-05-02
@AlexanderMint

Judging by the documentation and personal experience, it is impossible. Although if the name column is unique among the tables used, it should work
.select(:name)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question