Thursday, February 10, 2011

named_scope DEPRECATION WARNING on Rails 3.0.3

While using named_scope in Rails 3.0.3
class Project < ActiveRecord::Base
  named_scope :completed,:conditions=>"finish = true" 
end
you will get DEPRECATION WARNING.
DEPRECATION WARNING: Base.named_scope has been deprecated, please use Base.scope instead. (called from C:/projects/myapp/app/models/project.rb:2)
 To fix this use scope instead of named_scope. Your new code will be:

class Project < ActiveRecord::Base
  scope :completed,:conditions=>"finish = true" 
end

No comments:

Post a Comment