This project is archived and is in readonly mode.
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
-
Rob Anderton March 8th, 2009 @ 11:16 PM
- Tag set to “active_record, bug, find_last, order, patch”
I also hit this bug today, I've attached a simple patch that fixes the problem along with an extra test case.
-
Repository March 9th, 2009 @ 01:30 PM
- State changed from “new” to “resolved”
(from [faf4ba6b79e56dde383a8761fb1f485fcd07c72b]) Allow find(:last) :order be a symbol [#2024 state:resolved]
Signed-off-by: Pratik Naik pratiknaik@gmail.com http://github.com/rails/rails/co...
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
Tags
Referenced by
- 2024 default_scope, :order => :symbol, and Model.last conflict. (from [faf4ba6b79e56dde383a8761fb1f485fcd07c72b]) Allow f...