B
B
Bogdan2017-11-27 15:46:31
Ruby on Rails
Bogdan, 2017-11-27 15:46:31

Creating a references migration to a different field name?

Hello. I create a migration

rails generate model ProductsMove institutions:referenses products:referenses amount:decimal{15,6}

and instead of the institution_id field, you need to create 2 fields with a link to the institutions table from_institution_id and to_institution_id .
Thank you.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey, 2018-01-22
@bogdan_uman

do not through referenses, but from_institution_id:integer, to_institution_id:integer and in the model write the
belongs_to from_institution, class_name: 'Institution'
belongs_to to_institution, class_name: 'Institution'

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question