Hello!
There is a Product model that has only one parameter, for example, age, which is taken from the record of the corresponding Age model, but this parameter may also belong to another model.
Entries of the Age model from which the parameter is taken for the Product model look like this:
Age.all id: 1, name: "Взрослый" id: 2, name: "Юниор" id: 3, name: "Детский" Now everything works through the belongs_to link:
class Product belongs_to :age ... end Table Schema Products
create_table "products", force: :cascade do |t| t.integer "age_id" .... end So generally the right thing to do? It confuses me that now Product belongs to a parameter, although it probably should be the other way around.
For example:
class Product has_one :age ... end and something on the back of the link.