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?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---