This project is archived and is in readonly mode.

#2024 ✓resolved
Zef Houssney

default_scope, :order => :symbol, and Model.last conflict.

Reported by Zef Houssney | February 20th, 2009 @ 12:02 AM | in 2.x

The problem occurs when using a symbol to define order in default_scope, and then calling Model.last.


# location.rb
default_scope :order => :descriptive_name

# console
>> Location.last
NoMethodError: private method `split' called for :descriptive_name:Symbol
  from /Library/Ruby/Gems/1.8/gems/activerecord-2.3.0/lib/active_record/base.rb:1537:in `reverse_sql_order'
  from /Library/Ruby/Gems/1.8/gems/activerecord-2.3.0/lib/active_record/base.rb:1526:in `find_last'
  from /Library/Ruby/Gems/1.8/gems/activerecord-2.3.0/lib/active_record/base.rb:614:in `find'
  from /Library/Ruby/Gems/1.8/gems/activerecord-2.3.0/lib/active_record/base.rb:629:in `last'
  from (irb):4

# But strings work:
default_scope :order => 'descriptive_name'

>> Location.last
# => works correctly

Model.first and other things I have tried work as expected.

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 »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

People watching this ticket

Attachments

Referenced by

Pages