这让我很难调试这个。在我从 SQLite3 迁移到 PostgreSQL 之前,它运行良好。令我感到奇怪的是,还有另一个控制器的代码几乎与此相同,并且该页面运行良好。有人可以帮我吗?
错误:
ActiveRecord::StatementInvalid in Good_posts#index
Showing c:/ruby/mangfeel/app/views/good_posts/index.html.erb where line #3 raised:
PG::Error: ERROR: syntax error at or near "desc"
LINE 1: ... "good_posts".* FROM "good_posts" ORDER BY like desc LIMIT...
^
: SELECT "good_posts".* FROM "good_posts" ORDER BY like desc LIMIT 15 OFFSET 0
导致问题的good_posts_controller:
def index
@good_posts = GoodPost.paginate(:page => params[:page], order: 'like desc', per_page: 15)
@good_client_ip = request.remote_ip.encode! 'utf-8'
respond_to do |format|
format.html # index.html.erb
format.json { render json: @good_posts }
end
end
post_controller,它具有类似的代码但工作正常:
def index
@posts = Post.paginate(:page => params[:page], order: 'created_at desc', per_page: 15)
@client_ip = request.remote_ip.encode! 'utf-8'
respond_to do |format|
format.html # index.html.erb
format.json { render json: @posts }
end
end
我感谢所有的帮助!