Rails 3 named_scope deprecation warning

Posted: December 31, 2010 in Ruby On Rails
Tags: , ,

Rails 3 named_scope

Slit difference named_scope syntax between Rails 2 and Rails 3

Rails 2.X :

class User < ActiveRecord::Base

named_scope :newest_user, :conditions => ["created_at >= ?", (Time.now.utc - 1.hour)]

end

Rails 3.x :

class User < ActiveRecord::Base

scope :newest_user, :conditions => ["created_at >= ?", (Time.now.utc - 1.hour)]

end

So, to avoid deprecation warning of “named_scope” in Rails 3.x just use “scope”.

Good Luck ;)

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s