2 ms·
This is a great change. We almost never use .find() anymore in our rails 2.3 projects and everything uses named_scope() or scoped() (which return relations). Th
by gdeglin 17y ago
This is a great change. We almost never use .find() anymore in our rails 2.3 projects and everything uses named_scope() or scoped() (which return relations). This change will discourage really bad practices that I've seen in a lot of rails code.
If you've been doing things right you won't need to change much code. If you've been doing them wrong you will likely see a significant performance increase after updating your code.
Here's a line from our 2.3.2 project (Get all organizations that the user is a fan of):
@user.organizations.scoped(:limit => 10).with_role("Fan")
And what it will look like after this change:
@user.organizations.limit(10).with_role("Fan")
- timmaah 17y agoYou can do the "after" right now. named_scope :limit, lambda { |num| { :limit => num } }