aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/models/ship.rb
Commit message (Collapse)AuthorAgeFilesLines
* Only nullify persisted has_one target associationsAgis-2015-08-241-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | Since after 87d1aba3c `dependent: :destroy` callbacks on has_one assocations run *after* destroy, it is possible that a nullification is attempted on an already destroyed target: class Car < ActiveRecord::Base has_one :engine, dependent: :nullify end class Engine < ActiveRecord::Base belongs_to :car, dependent: :destroy end > car = Car.create! > engine = Engine.create!(car: car) > engine.destroy! # => ActiveRecord::ActiveRecordError: cannot update a > destroyed record In the above case, `engine.destroy!` deletes `engine` and *then* triggers the deletion of `car`, which in turn triggers a nullification of `engine.car_id`. However, `engine` is already destroyed at that point. Fixes #21223.
* Correctly ignore `mark_for_destruction` without `autosave`Sean Griffin2015-07-201-0/+1
| | | | | | | | | As per the docs, `mark_for_destruction` should do nothing if `autosave` is not set to true. We normally persist associations on a record no matter what if the record is a new record, but we were always skipping records which were `marked_for_destruction?`. Fixes #20882
* Ensure cyclic associations w/ autosave don't cause duplicate errorsSean Griffin2015-07-181-0/+11
| | | | | | | | | | | | | | | | This code is so fucked. Things that cause this bug not to replicate: - Defining the validation before the association (we end up calling `uniq!` on the errors in the autosave validation) - Adding `accepts_nested_attributes_for` (I have no clue why. The only thing it does that should affect this is adds `autosave: true` to the inverse reflection, and doing that manually doesn't fix this). This solution is a hack, and I'm almost certain there's a better way to go about it, but this shouldn't cause a huge hit on validation times, and is the simplest way to get it done. Fixes #20874.
* Don't redefine autosave association callbacks in nested attrsSean Griffin2015-01-281-0/+1
| | | | | | | | These callbacks will already have been defined when the association was built. The check against `reflection.autosave` happens at call time, not at define time, so simply modifying the reflection is sufficient. Fixes #18704
* Deprecate `false` as the way to halt AR callbacksclaudiob2015-01-021-1/+1
| | | | | | | | | | Before this commit, returning `false` in an ActiveRecord `before_` callback such as `before_create` would halt the callback chain. After this commit, the behavior is deprecated: will still work until the next release of Rails but will also display a deprecation warning. The preferred way to halt a callback chain is to explicitly `throw(:abort)`.
* Pass symbol as an argument instead of a blockErik Michaels-Ober2014-11-291-1/+1
|
* Fixed custom validation context bug where childEric Chahin2014-05-011-0/+6
| | | | | | | | associations were not being saved. Fixes #13854. [Eric Chahin, Aaron Nelson, & Kevin Casey]
* Revert "context in validation goes through has many relationship"Aaron Patterson2014-02-201-8/+0
| | | | This reverts commit 5e3d466d52fa4e9a42c3a1f8773a7c31da875e48.
* context in validation goes through has many relationshipKevin Casey2014-02-081-0/+8
|
* Nested records (re: autosave) are now updated even when the intermediate ↵Ian White2010-05-181-1/+2
| | | | | | parent record is unchanged [#4242 state:resolved] Signed-off-by: José Valim <jose.valim@gmail.com>
* Rollback the transaction when one of the autosave associations fails to ↵Eloy Duran2010-01-081-0/+6
| | | | save. [#3391 state:resolved]
* Refactored previous changes to nested attributes.Eloy Duran2009-12-281-0/+2
|
* Define autosave association callbacks when using accepts_nested_attributes_for.Eloy Duran2009-11-071-1/+1
| | | | | | | This way we don't define all the validation methods for all associations by default, but only when needed. [#3355 state:resolved]
* Define autosave association validation methods only when needed. [#3161 ↵Alexey Kovyrin2009-09-121-1/+1
| | | | | | state:resolved] Signed-off-by: Eloy Duran <eloy.de.enige@gmail.com>
* Changed API of NestedAttributes to take an array, or hash with index keys, ↵Lance Ivy2009-02-131-2/+2
| | | | | | | | of hashes that have the id on the inside of the attributes hash and updated the FormBuilder to produce such hashes. Also fixed NestedAttributes with composite ids. Signed-off-by: Michael Koziarski <michael@koziarski.com> Signed-off-by: Eloy Duran <eloy.de.enige@gmail.com> [#1892 state:committed]
* Add support for nested object forms to ActiveRecord and the helpers in ↵Eloy Duran2009-02-011-0/+7
| | | | | | | | ActionPack Signed-Off-By: Michael Koziarski <michael@koziarski.com> [#1202 state:committed]
* move assets and modelsJeremy Kemper2008-01-181-0/+3
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8657 5ecf4fe2-1ee6-0310-87b1-e25e094e27de