Interesting Things
has_many and belongs_to associations can now automatically create back references each other, thanks to a Backport of :inverse_of from Rails 3 to rails 2.3.6. This allows us to keep our object graphs more correct and avoid situations where we have 2 copies of the same object because the object graph is walked in reverse. Here’s how to use it:
class Parent < ActiveRecord::Base
has_one :child, :inverse_of => :parent
accepts_nested_attributes_for :child
end
class Child < ActiveRecord::Base
belongs_to :parent
validates_presence_of :parent
end