Interesting Things
has_many
andbelongs_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 endContinue reading
The post Standup 5/28/2010: rails new :inverse_of association option automatically creates backreferences appeared first on Pivotal Labs.