Created
August 12, 2009 16:20
-
-
Save nicolasblanco/166596 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Problem with :order, all and will_paginate ? | |
# | |
# This one should NOT work, but will_paginate seems not to use the :order option... | |
# | |
>> User.all.paginate(:page => 1, :order => "superpipolol") | |
=> [#<User id: 1, last_name: "Team", first_name: "The-Sphere", email: "admin@the-sphere.com", ...] | |
# This fails as expected. | |
# | |
>> User.paginate(:all, :page => 1, :order => "superpipolol") | |
=> ActiveRecord::StatementInvalid: Mysql::Error: Unknown column 'superpipolol' in 'order clause': SELECT * FROM `users` ORDER BY superpipolol LIMIT 0, 30 | |
# This fails as expected with a custom named_scope too. | |
# | |
>> User.latest(5).paginate(:page => 1, :order => "superpipolol") | |
=> ActiveRecord::StatementInvalid: Mysql::Error: Unknown column 'superpipolol' in 'order clause': SELECT * FROM `users` ORDER BY superpipolol, created_at DESC LIMIT 0, 30 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment