I have a page which simply displays all of the Links in my database sorted by the voteCount. Here is the controller:
class PagesController < ApplicationController
def index
params[:per_page] ||= 5
params[:page] ||= 1
@links = Link.order('voteCount DESC').paginate(:page => params[:page], :per_page => params[:per_page])
end
end
I save query the database using the paginate plugin, and prepend it with:
.order('voteCount DESC')
When I run this command on my local server, it runs fine. However, as soon as I deploy it to heroku, it fails. This is the output I get when I check the logs/execute it in the console:
Link Load (2.0ms) SELECT "links".* FROM "links" ORDER BY voteCount DESC LIMIT 5 OFFSET 0
ActiveRecord::StatementInvalid: PG::Error: ERROR: column "votecount" does not exist
LINE 1: SELECT "links".* FROM "links" ORDER BY voteCount DESC LIMI...
^
I've checked using the console, the voteCount column is definitely there. This might be due to the fact that my local environment runs sqlite3 and heroku makes me use postgres ....
Any help would be really appreciated. Thanks.