1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/activerecord/lib/active_record/associations
Chris Thompson ebd7cc6f45 Fix #8856 Ensure has_one association=(associate) triggers save.
activerecord/lib/active_record/associations.rb states:

    # [association=(associate)]
    #   Assigns the associate object, extracts the primary key, sets it as the foreign key,
    #   and saves the associate object.

Since commit 42dd5d9f29 to fix #7191, this
is no longer the case if the associate has changed, but is the same
object. For example:

    # Pirate has_one :ship
    pirate = Pirate.create!(catchphrase: "A Pirate")
    ship = pirate.build_ship(name: 'old name')
    ship.save!

    ship.name = 'new name'
    pirate.ship = ship

That last line should trigger a save. Although we are not changing the
association, the associate (ship) has changed.
2013-04-30 16:14:16 -07:00
..
builder Lookup the class at runtime, not when the association is built 2013-04-24 15:07:39 +01:00
join_dependency Merge branch 'master' of github.com:lifo/docrails 2013-04-11 22:58:14 +05:30
preloader Avoid iterating over records hash when not necessary 2013-04-07 12:14:53 -03:00
alias_tracker.rb Remove ActiveRecord::Model 2012-10-26 15:51:02 +01:00
association.rb Merge branch 'master' of github.com:lifo/docrails 2013-04-11 22:58:14 +05:30
association_scope.rb use | to have more intent revealing code 2013-04-04 17:59:02 -04:00
belongs_to_association.rb Adding a bang to method name of raise_on_type_mismatch. 2013-03-21 11:58:36 -04:00
belongs_to_polymorphic_association.rb Adding a bang to method name of raise_on_type_mismatch. 2013-03-21 11:58:36 -04:00
collection_association.rb Updated the error message for +find+ on an inverse_of association 2013-04-01 18:34:21 -04:00
collection_proxy.rb Merge branch 'master' of github.com:lifo/docrails 2013-04-11 22:58:14 +05:30
has_and_belongs_to_many_association.rb Deprecate #connection in favour of accessing it via the class 2013-03-09 15:16:15 -05:00
has_many_association.rb Update other counter caches on destroy 2013-03-20 13:43:07 -07:00
has_many_through_association.rb Adding a bang to method name of raise_on_type_mismatch. 2013-03-21 11:58:36 -04:00
has_one_association.rb Fix #8856 Ensure has_one association=(associate) triggers save. 2013-04-30 16:14:16 -07:00
has_one_through_association.rb Rename update_attributes method to update, keep update_attributes as an alias 2013-01-03 11:51:21 -05:00
join_dependency.rb rdoc for some of the methods in JoinDependency 2013-04-10 14:33:39 -04:00
join_helper.rb Improve the derivation of HABTM assocation join table names 2012-06-22 06:27:11 +01:00
preloader.rb refactoring to_sym of Symbol in preload 2013-01-02 15:57:01 +01:00
singular_association.rb This is comment for singular association. 2012-11-02 01:34:29 +09:00
through_association.rb optimize some code around merge 2013-04-03 20:18:49 +05:30