Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Commits on May 4, 2009
  1. Murray Steele Jeremy Kemper

    Providing support for :inverse_of as an option to associations.

    h-lame authored jeremy committed
    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
    class Face < ActiveRecord::Base
      belongs_to :man, :inverse_of => :face
    m = Man.first
    f = m.face
    Without :inverse_of m and would be different instances of the same object ( being pulled from the database again).  With these new :inverse_of options m and 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 <>
    Signed-off-by: Jeremy Kemper <>
Something went wrong with that request. Please try again.