Forum: Rails-core (closed, excessive spam) Named scope with bang

Posted by Ryan Bates (Guest)
on 2008-06-10 17:01
(Received via mailing list)
I think it would be great if named scopes had a bang (!) variation
which applies to the current scope instead of returning a new scope.
This is very useful if you need to apply scopes conditionally like
this:

topics = Topic.approved
topics.replied! if only_show_replied?
topics.scoped! :limit => limit if limit

I would love to get some feedback on this. Would you like to see the
same thing? You can find the patch here:
http://rails.lighthouseapp.com/projects/8994/tickets/368

Ryan
Posted by Trevor Turk (Guest)
on 2008-06-10 21:40
(Received via mailing list)
On Jun 10, 9:59 am, Ryan Bates <bates.r...@gmail.com> wrote:
> I think it would be great if named scopes had a bang (!) variation
> which applies to the current scope instead of returning a new scope.

I haven't tested this, so I can't exactly give it the old +1, but I
expect it to come in handy in the future and it seems like a natural
fit.

- Trevor
This topic is locked and can not be replied to.