| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
| |
manages the association, and a CollectionProxy class which is *only* a proxy. Singular associations no longer have a proxy. See CHANGELOG for more.
|
| |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
| |
second parameter to build_assoc or create_assoc, and the existing associated object would be untouched (the foreign key would not be nullified, and it would not be deleted). If you want behaviour similar to this you can do the following things:
* Use :dependent => :nullify (or don't specify :dependent) if you want to prevent the existing associated object from being deleted
* Use has_many if you actually want multiple associated objects
* Explicitly set the foreign key if, for some reason, you really need to have multiple objects associated with the same has_one. E.g.
previous = obj.assoc
obj.create_assoc
previous.update_attributes(:obj_id => obj.id)
|
| |
|
| |
|
| |
|
|
|
|
|
|
| |
[#4645 state:resolved]
Signed-off-by: José Valim <jose.valim@gmail.com>
|
| |
|
|
|
|
|
|
| |
InverseOfAssociationNotFoundError if the supplied class doesn't have the appropriate association. [#3520 state:resolved]
Signed-off-by: Eloy Duran <eloy.de.enige@gmail.com>
|
|
|
|
|
|
|
|
| |
polymorphic belongs_to associations. [#3520 state:resolved]
Also add a new test for polymorphic belongs_to that test direct accessor assignment, not just .replace assignment.
Signed-off-by: Eloy Duran <eloy.de.enige@gmail.com>
|
|
|
|
| |
Signed-off-by: Eloy Duran <eloy.de.enige@gmail.com>
|
|
|
|
|
|
|
|
| |
[#3513 state:resolved]
Get rid of a duplicate set_inverse_instance call if you use new_record(true) (e.g. you want to replace the existing instance).
Signed-off-by: Eloy Duran <eloy.de.enige@gmail.com>
|
|
|
|
| |
Signed-off-by: Eloy Duran <eloy.de.enige@gmail.com>
|
|
|
|
| |
Signed-off-by: Michael Koziarski <michael@koziarski.com>
|
|
|
|
| |
Signed-off-by: Michael Koziarski <michael@koziarski.com>
|
|
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>
|