1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/activerecord/test
Murray Steele ccea98389a Providing support for :inverse_of as an option to associations.
You can now add an :inverse_of option to has_one, has_many and belongs_to associations.  This is best described with an example:

class Man < ActiveRecord::Base
  has_one :face, :inverse_of => :man
end

class Face < ActiveRecord::Base
  belongs_to :man, :inverse_of => :face
end

m = Man.first
f = m.face

Without :inverse_of m and f.man would be different instances of the same object (f.man being pulled from the database again).  With these new :inverse_of options m and f.man are the same in memory instance.

Currently :inverse_of supports has_one and has_many (but not the :through variants) associations.  It also supplies inverse support for belongs_to associations where the inverse is a has_one and it's not a polymorphic.

Signed-off-by: Murray Steele <muz@h-lame.com>
Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
2009-05-04 15:27:39 -07:00
..
assets move assets and models 2008-01-18 07:27:03 +00:00
cases Providing support for :inverse_of as an option to associations. 2009-05-04 15:27:39 -07:00
connections Adding AR tests for JDBC connections 2009-01-26 16:08:44 +13:00
fixtures Providing support for :inverse_of as an option to associations. 2009-05-04 15:27:39 -07:00
migrations Made migrations transactional for PostgreSQL [#834 state:resolved] 2008-08-22 14:46:25 -07:00
models Providing support for :inverse_of as an option to associations. 2009-05-04 15:27:39 -07:00
schema Providing support for :inverse_of as an option to associations. 2009-05-04 15:27:39 -07:00
config.rb Merge branch 'ar-test-cleanup' of git://git.geeksomnia.com/rails 2008-01-21 17:20:51 +00:00