I'm having: colour model with id,name,value car model, id,name,colour_id chair model id,name,colour_id - i have a many to one relation, correct? - different type of objects have a colour. putting for the car and chair model an attribute has_one :colour, is't enough. I thought that having: class Car<ActiveRecord::Base has_one :colour def before_create() colour = Color.new colour.name = 'red' color.save end end when I would create a Car object and save-it i should have in the database for that record color_id <> 0, but i found that it is NULL. -what did I do wrong?
on 2007-01-19 18:03