This project is archived and is in readonly mode.
with_scope merges create conditions incorrectly
Reported by Manfred Stienstra | March 10th, 2009 @ 11:32 AM | in 2.x
To make chained named scopes work, with_scope was changed to do a reverse merge of create conditions. This breaks normal use of with_scope for create conditions. For example:
comment = nil
Comment.with_scope(:create => {:conditions => {:approved => true}}) do
Comment.with_scope(:create => {:conditions => {:approved => false}}) do
comment = Comment.new
end
end
comment.approved? #=> true
My solution is to add a new action to with_scope: the reverse_merge. If you want, you can pull the change from http://github.com/Manfred/rails/...
Comments and changes to this ticket
-
Repository March 10th, 2009 @ 11:50 AM
- State changed from new to resolved
(from [c3aa2bcdcffb42f578b0e89fe08e1c4e234ccf3b]) Ensure nested with_scope merges conditions inside out [#2193 state:resolved]
Signed-off-by: Pratik Naik pratiknaik@gmail.com http://github.com/rails/rails/co...
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
<h2 style="font-size: 14px">Tickets have moved to Github</h2>
The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>
People watching this ticket
Attachments
Referenced by
- 2193 with_scope merges create conditions incorrectly (from [c3aa2bcdcffb42f578b0e89fe08e1c4e234ccf3b]) Ensure ...
- 2257 default_scope with named_scope or scoped merge broken on 2.3 Reference: #2193
- 2257 default_scope with named_scope or scoped merge broken on 2.3 @Manfred, Pratik: any chance we can rollback #2193? Seems...