Answer the question
In order to leave comments, you need to log in
How to write data to two tables?
There are two tables (cars and colors).
The cars table has
id brand power color_id fields
The colors table has
id color rarity fields
The content of the models
class Car < ActiveRecord::Base
belongs_to :color
...
end
class Color < ActiveRecord::Base
...
end
Answer the question
In order to leave comments, you need to log in
model car
belongs_to :color
controller
@car = Car.new(:power => 106)
@car.color = Color.where(:id => 6).first
@car.save Advertisement
site?
This is just a report on the conversion of a project from a previous version to a newer one, close it and move on. You can read what kind of warnings, maybe something useful will be there.
put the picture, please, on habrastorage - nothing is visible,
but so far no errors are visible,
one warning,
but you can live and work with it further
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question