This project is archived and is in readonly mode.
Improved named_scope to be used like as with_scope
-
Genki Takiuchi
Attached the patch.
-
Genki Takiuchi
Removed mail headers from the patch.
-
Ryan Bates
I just needed this functionality not too long ago, and the implementation looks nice and simple. However, it looks like tests are missing, could you add some?
-
Ryan Bates
I've been playing around with this a little bit and found out you can completely remove the "with" method on the Scope class and it will still behave properly. This is because when you call "with" it will be delegated to the proxy scope and already apply with_scope.
I propose not using the "with" method at all and just sticking to with_scope. This required a couple minor changes but I've attached a patch which does this.
User.active.with_scope do User.count #=> equals to User.active.count end -
Genki Takiuchi
Ryan, I agree with you.
-
Pratik
- State changed from new to wontfix
This is not very with_scope like as with_scope was made a private method after people started abusing it in around_filter, which is against Rails way of doing things.
This should still work, however it should be a protected method.
Might be a good idea to discuss in the mailing list.
Thanks.
