This project is archived and is in readonly mode.

#2199 ✓ duplicate
Peter Leonhardt

default_scope Errors with named_scope

Reported by Peter Leonhardt | March 10th, 2009 @ 06:44 PM | in 2.x

When using default_scope in conjunction with named_scope, a default_scope that has been defined with :condition as a String, rather than a hash will throw a "TypeError: can't convert String into Hash" from


activerecord/lib/active_record/base.rb:2132: in 'merge'
activerecord/lib/active_record/base.rb:2132: in 'with_scope'
activerecord/lib/active_record/base.rb:2110: in 'each'
activerecord/lib/active_record/base.rb:2110: in 'inject'
activerecord/lib/active_record/base.rb:2110: in 'with_scope'

The default scope works find on its own, but calling a named_scope will throw the error when, presumably, trying to merge the scopes.


default_scope {:conditions => ["expires_at > ?", Time.now] }
named_scope :globals { :conditions => {:global => true } }

Comments and changes to this ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

Tickets have moved to Github

The new ticket tracker is available at https://github.com/rails/rails/issues

Shared Ticket Bins

Referenced by

Pages