From 8fb0de2cae8e6f26c71ab8e4267d3841a38a29b9 Mon Sep 17 00:00:00 2001 From: Paul Nikitochkin Date: Sun, 14 Jul 2013 17:32:56 +0300 Subject: Removed where_values_hash from AR::NullRelation In order to build associated records for owners which has not been saved need to get where values to use as default attributes. But for new record owner uses `ActiveRecord::NullRelation` which override `where_values_hash` to return empty hash stub. `where_values_hash` is not used to invoke any sql query, but good to build others chains (even will be never executed) like: ```ruby post = Post.new admin_comment = post.admin_comments.build assert_equal 'Admin', admin_comment.author ``` Closes #11376, #11676, #11675 --- activerecord/CHANGELOG.md | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'activerecord/CHANGELOG.md') diff --git a/activerecord/CHANGELOG.md b/activerecord/CHANGELOG.md index 810a2c668d..9cf619f4c2 100644 --- a/activerecord/CHANGELOG.md +++ b/activerecord/CHANGELOG.md @@ -1,3 +1,10 @@ +* Objects intiantiated using a null relationship will now retain the + attributes of the where clause. + + Fixes: #11676, #11675, #11376 + + *Paul Nikitochkin*, *Peter Brown*, *Nthalk* + * Fixed `ActiveRecord::Associations::CollectionAssociation#find` when using `has_many` association with `:inverse_of` and finding an array of one element, it should return an array of one element too. -- cgit v1.2.3