File tree Expand file tree Collapse file tree 2 files changed +8
-3
lines changed
activerecord/lib/active_record Expand file tree Collapse file tree 2 files changed +8
-3
lines changed Original file line number Diff line number Diff line change @@ -2092,6 +2092,8 @@ def convert_number_column_value(value)
2092
2092
end
2093
2093
2094
2094
def populate_with_current_scope_attributes
2095
+ return unless self . class . scope_attributes?
2096
+
2095
2097
self . class . scope_attributes . each do |att , value |
2096
2098
send ( "#{ att } =" , value ) if respond_to? ( "#{ att } =" )
2097
2099
end
Original file line number Diff line number Diff line change @@ -47,15 +47,18 @@ def scope_attributes # :nodoc:
47
47
if current_scope
48
48
current_scope . scope_for_create
49
49
else
50
- # Return an empty hash in the simple case
51
- return { } unless default_scopes . any?
52
-
53
50
scope = relation . clone
54
51
scope . default_scoped = true
55
52
scope . scope_for_create
56
53
end
57
54
end
58
55
56
+ ##
57
+ # Are there default attributes associated with this scope?
58
+ def scope_attributes? # :nodoc:
59
+ current_scope || default_scopes . any?
60
+ end
61
+
59
62
# Adds a class method for retrieving and querying objects. A \scope represents a narrowing of a database query,
60
63
# such as <tt>where(:color => :red).select('shirts.*').includes(:washing_instructions)</tt>.
61
64
#
You can’t perform that action at this time.
0 commit comments