RubyFlow : Ruby Community Link Blog

Home   Submit   Sign Up   Log In   leaders   Twitter   RSS Feed  
 

Named Scopes Are Dead

Lots of people love using named scopes in Rails 2. However, in Rails 3 they're not only more or less obsolete but can also hinder productiveness in teams by being update blockers. Read about the reasons and alternatives in the railway blog.

Comments

Fixed: http://github.com/rails/rails/commit/181c414baa877d748671d03fb09499c10f81ec02
https://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets/4142-arel-methods-in-scope-cause-issues-with-non-existent-tables
The workaround looks messy to me.anonymous - March 10, 2010 12:03
When I first gave AR 3 a go, I wondered if you could just use class methods for the same benefits as scopes considering the lazy evaluation. Glad someone else actually tried it and confirms it works ;-) That class << self stuff is a big gangly though.. def self.published reads somewhat nicer.PeterCooper - March 10, 2010 21:54
>That class
I agree with you on this one but I have seen several posts which suggest that this is not the best practice... (I have yet to understand why).Anonymous Coward - March 11, 2010 14:56
Peter: I prefer class clemens - March 13, 2010 23:52
Nothing wrong with a preference, of course, but it's still more verbose (and if used in anger leads to situations where you're not entirely sure if a method is a class or instance method, unless you go looking for the associated class definition).PeterCooper - March 15, 2010 01:50

Post a Comment

Note: If you are a registered user, you can log in to populate these fields.

You may use ONLY these HTML tags to format your comment:
<a href="" title=""> <b> <blockquote> <code> <em> <i> <strong>
Do NOT use <p> tags. Just use newlines :-)

t
a
g
u
r
i
t
a
i
E willy
n
t
H tits