Project

General

Profile

Actions

Patch #12499

closed

Use lambda in model scopes

Added by Jean-Baptiste Barth almost 12 years ago. Updated almost 12 years ago.

Status:
Closed
Priority:
Normal
Category:
Plugin API
Target version:
Start date:
Due date:
% Done:

0%

Estimated time:

Description

Yesterday I had to monkey-patch "Group" in a plugin, and it turned out to be really difficult because there's a scope defined in the Group class which doesn't use lambda. In this case, the scope is evaluated directly, which fails with "Could not find table users" for instance if you're in a "db:migrate" phase and your database is empty.

Hence I propose moving all scopes to their lambda form so that these difficulties disappear for plugin development.

One more thing, using scopes without lambda (or a call-able) will be deprecated in Rails 4 and probably removed in Rails 4.1 (see this commit).

Let me know what you think. If you're OK with this change I can take care of verifying all models, running tests and making the change everywhere...

Actions

Also available in: Atom PDF