在我使用 SQLite3 的开发过程中,我正在将我的应用程序部署到 heroku(和 n00b 一样)。我部署到 Heroku,但我收到特定页面的错误。我加载了 Postgresql 作为我的开发数据库,我注意到我的错误是由于排序功能而发生的。这在 SQLite3 中工作得很好,但在 Postgresql 中被破坏了。有人对如何更改语法以使用 Postgresql 有任何想法吗?
def index
@users = User.paginate(:page => params[:page], :per_page => 100).search(params[:search]).find(:all, :order => sort_order('id'))
end
private
#called to sort the table. taking in case insensitive
def sort_order(default)
"LOWER( #{(params[:c] || default.to_s).gsub(/[\s;'\"]/,'')} ) #{params[:d] == 'down' ? 'DESC' : 'ASC'}"
end
这是我收到的错误
ActiveRecord::StatementInvalid in UsersController#index
PG::UndefinedFunction: ERROR: function lower(integer) does not exist LINE 1: SELECT "users".* FROM "users" ORDER BY LOWER( id ) DESC L... ^ HINT: No function matches the given name and argument types. You might need to add explicit type casts. : SELECT "users".* FROM "users" ORDER BY LOWER( id ) DESC LIMIT 100 OFFSET 0