search for: horse_id

Displaying 1 result from an estimated 1 matches for "horse_id".

2010 May 11
1
has_one/belongs_to -- accessing the subordinate
...? I *think* the after_create callback is a good choice, but I discovered an oddity while trying it. F''rinstance, if every horse has a carriage: ============ ActiveRecord::Schema.define do create_table(:horses) {|t| t.timestamps } create_table(:carriages) {|t| t.timestamps; t.integer :horse_id } end class Horse < ActiveRecord::Base after_create :create_carriage has_one :carriage, :dependent => :destroy private def create_carriage Carriage.create(:horse => self) end end class Carriage < ActiveRecord::Base belongs_to :horse end ============ This works fine...