I have the following two ActiveRecord queries in an application_helper.rb file:
@left_menu = Page.select(‘id, menu_name’).where(:published => true, :left_menu => true).order(“sort”)
Also can be written as:
@left_menu = Page.select(‘id, menu_name’).where(:published => true, :left_menu => true).order(“‘sort’ ASC”)
and:
@left_menu = Page.find(:all, :conditions => {:published => true, :left_menu => true}, :order => :sort)
Why does the first one fail to sort on the ‘sort’ column, while the second one does not? Both work in SQLite, but only the second one works in MySQL.
Any ideas?
it’s the quote in ther order params .
the query generated will be (similar to)
its the char ‘ quote . It’s wrong sql syntax , it’s going to order by costant value not column value . sqlite allow it , mysql not.
try to simple use
without single quote in the order chain method parameters.
sorry for my english.
have a nice day