diff options
author | Pablo Ifran <pabloifran@gmail.com> | 2012-10-22 09:42:42 -0200 |
---|---|---|
committer | Pablo Ifran <pabloifran@gmail.com> | 2012-10-22 09:42:42 -0200 |
commit | e041a50f2917f82950f9e5666f966d8992afd45d (patch) | |
tree | 9f4d2e3aa88f28dba9d7a1d24d46977e0642a1eb /activerecord/CHANGELOG.md | |
parent | 3e6b2f5d38e0f31db3fb0fcd3bbab92666a0e3e2 (diff) | |
parent | ae27acb342c575ce19d5ad78cb13ba23f826fab1 (diff) | |
download | rails-e041a50f2917f82950f9e5666f966d8992afd45d.tar.gz rails-e041a50f2917f82950f9e5666f966d8992afd45d.tar.bz2 rails-e041a50f2917f82950f9e5666f966d8992afd45d.zip |
Merge branch 'master' of https://github.com/lifo/docrails
Conflicts:
activerecord/lib/active_record/callbacks.rb
Diffstat (limited to 'activerecord/CHANGELOG.md')
-rw-r--r-- | activerecord/CHANGELOG.md | 75 |
1 files changed, 73 insertions, 2 deletions
diff --git a/activerecord/CHANGELOG.md b/activerecord/CHANGELOG.md index 9abfe2e6fd..ffd19a5334 100644 --- a/activerecord/CHANGELOG.md +++ b/activerecord/CHANGELOG.md @@ -1,5 +1,67 @@ ## Rails 4.0.0 (unreleased) ## +* Add `find_or_create_by`, `find_or_create_by!` and + `find_or_initialize_by` methods to `Relation`. + + These are similar to the `first_or_create` family of methods, but + the behaviour when a record is created is slightly different: + + User.where(first_name: 'Penélope').first_or_create + + will execute: + + User.where(first_name: 'Penélope').create + + Causing all the `create` callbacks to execute within the context of + the scope. This could affect queries that occur within callbacks. + + User.find_or_create_by(first_name: 'Penélope') + + will execute: + + User.create(first_name: 'Penélope') + + Which obviously does not affect the scoping of queries within + callbacks. + + The `find_or_create_by` version also reads better, frankly. + + If you need to add extra attributes during create, you can do one of: + + User.create_with(active: true).find_or_create_by(first_name: 'Jon') + User.find_or_create_by(first_name: 'Jon') { |u| u.active = true } + + The `first_or_create` family of methods have been nodoc'ed in favour + of this API. They may be deprecated in the future but their + implementation is very small and it's probably not worth putting users + through lots of annoying deprecation warnings. + + *Jon Leighton* + +* Fix bug with presence validation of associations. Would incorrectly add duplicated errors + when the association was blank. Bug introduced in 1fab518c6a75dac5773654646eb724a59741bc13. + + *Scott Willson* + +* Fix bug where sum(expression) returns string '0' for no matching records + Fixes #7439 + + *Tim Macfarlane* + +* PostgreSQL adapter correctly fetches default values when using multiple schemas and domains in a db. Fixes #7914 + + *Arturo Pie* + +* Learn ActiveRecord::QueryMethods#order work with hash arguments + + When symbol or hash passed we convert it to Arel::Nodes::Ordering. + If we pass invalid direction(like name: :DeSc) ActiveRecord::QueryMethods#order will raise an exception + + User.order(:name, email: :desc) + # SELECT "users".* FROM "users" ORDER BY "users"."name" ASC, "users"."email" DESC + + *Tima Maslyuchenko* + * Rename `ActiveRecord::Fixtures` class to `ActiveRecord::FixtureSet`. Instances of this class normally hold a collection of fixtures (records) loaded either from a single YAML file, or from a file and a folder @@ -50,6 +112,10 @@ app processes (so long as the code in those processes doesn't contain any references to the removed column). + The `partial_updates` configuration option is now renamed to + `partial_writes` to reflect the fact that it now impacts both inserts + and updates. + *Jon Leighton* * Allow before and after validations to take an array of lifecycle events @@ -269,6 +335,11 @@ *Ari Pollak* +* Fix AR#dup to nullify the validation errors in the dup'ed object. Previously the original + and the dup'ed object shared the same errors. + + * Christian Seiler* + * Raise `ArgumentError` if list of attributes to change is empty in `update_all`. *Roman Shatsov* @@ -578,9 +649,9 @@ * `find_or_initialize_by_...` can be rewritten using `where(...).first_or_initialize` * `find_or_create_by_...` can be rewritten using - `where(...).first_or_create` + `find_or_create_by(...)` or where(...).first_or_create` * `find_or_create_by_...!` can be rewritten using - `where(...).first_or_create!` + `find_or_create_by!(...) or `where(...).first_or_create!` The implementation of the deprecated dynamic finders has been moved to the `activerecord-deprecated_finders` gem. See below for details. |