In my application I have 2 classes like this:
class City < ActiveRecord::Base
has_many :events
end
class Event < ActiveRecord::Base
belongs_to :city
attr_accessible :title, :city_id
end
If I create city object:
city = City.create!(:name => 'My city')
and then pass parameters to create event like this:
event = Event.create!(:name => 'Some event', :city => city)
I get
event.city_id => null
So the question is - is it possible to pass parameters in such a way to get my objects connected, what am I doing wrong? Or should I use other ways (like
event.city = city
) ?