diff options
author | Francesco Rodriguez <lrodriguezsanc@gmail.com> | 2012-05-28 19:56:54 -0500 |
---|---|---|
committer | Francesco Rodriguez <lrodriguezsanc@gmail.com> | 2012-05-28 19:57:43 -0500 |
commit | 39f0698405f8d52984f614d2aecafc514da9a3c5 (patch) | |
tree | 81dfb1c5627c125f534801232b2f66ac8b48240f /activerecord/CHANGELOG.md | |
parent | 68f23bea6b3eec48f26e87ab9cdf3ff361820831 (diff) | |
download | rails-39f0698405f8d52984f614d2aecafc514da9a3c5.tar.gz rails-39f0698405f8d52984f614d2aecafc514da9a3c5.tar.bz2 rails-39f0698405f8d52984f614d2aecafc514da9a3c5.zip |
Add support for CollectionAssociation#delete by Fixnum or String
I found the next issue between CollectionAssociation `delete`
and `destroy`.
class Person < ActiveRecord::Base
has_many :pets
end
person.pets.destroy(1)
# => OK, returns the destroyed object
person.pets.destroy("2")
# => OK, returns the destroyed object
person.pets.delete(1)
# => ActiveRecord::AssociationTypeMismatch
person.pets.delete("2")
# => ActiveRecord::AssociationTypeMismatch
Adding support for deleting with a fixnum or string like
`destroy` method.
Diffstat (limited to 'activerecord/CHANGELOG.md')
-rw-r--r-- | activerecord/CHANGELOG.md | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/activerecord/CHANGELOG.md b/activerecord/CHANGELOG.md index 8f1f315e42..1a8e233a51 100644 --- a/activerecord/CHANGELOG.md +++ b/activerecord/CHANGELOG.md @@ -1,5 +1,18 @@ ## Rails 4.0.0 (unreleased) ## +* Added support to `CollectionAssociation#delete` for passing `fixnum` + or `string` values as record ids. This finds the records responding + to the `id` and executes delete on them. + + class Person < ActiveRecord::Base + has_many :pets + end + + person.pets.delete("1") # => [#<Pet id: 1>] + person.pets.delete(2, 3) # => [#<Pet id: 2>, #<Pet id: 3>] + + *Francesco Rodriguez* + * Deprecated most of the 'dynamic finder' methods. All dynamic methods except for `find_by_...` and `find_by_...!` are deprecated. Here's how you can rewrite the code: |