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/schema
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
..
mysql_specific_schema.rb Create mysql binary_fields table with latin1 character set as with utf8 all the limits would have to be divided by 3 to get the expected text types 2008-08-26 01:49:19 -07:00
postgresql_specific_schema.rb Ensure postgresql tests work when starting from scratch. 2008-04-30 21:54:54 +12:00
schema.rb Providing support for :inverse_of as an option to associations. 2009-05-04 15:27:39 -07:00
schema2.rb Use schema.rb for all databases 2008-04-22 13:55:13 +12:00
sqlite_specific_schema.rb Use schema.rb for all databases 2008-04-22 13:55:13 +12:00