Answer the question
In order to leave comments, you need to log in
How in Rails, when creating one model, take data from other models?
Hello!
I want to create a table where the data of automobile tires would be stored. Tires have parameters such as name, load index and speed index. The indexes themselves and their corresponding values are stored in two other tables.
There are three models.
Tire: (belongs_to :load_index; belongs_to :speed_index)
name:string
speed_index:references
load_index:references
LoadIndex: (has_many :tires)
index:integer (Тут индекс нагрузки)
value:integer (Тут значение нагрузки, соответствующее индексу нагрузки)
SpeedIndex: (has_many :tires)
index:string (Тут индекс скорости)
value:integer (Тут значение скорости, соответствующее индексу скорости)
Answer the question
In order to leave comments, you need to log in
There is.
And if you need something else, arrange the question in code blocks and describe the task normally (for example, in more detail)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question