0

My Rails App works perfect local and on my own linux root (with sqlite to test it)

After uploading it to heroku, i have a small problem.

Half of my requests does not work anymore.

All Requests with a ".where()" condition are broken.

Here is a small code snippet from my controller:

def GameModeB
  ActiveRecord::Base.include_root_in_json = false
  @highscore = Highscore.where("gamemode = \"b\"").order("points DESC").limit(100)

  respond_to do |format|
    format.html # index.html.erb
    format.xml  { render :xml => @highscore }
    format.json  { render :json =>  @highscore}
  end
end

This is my errorlog from heroku log

2011-12-07T12:21:08+00:00 app[web.1]: LINE 1: ...highscores".* FROM "highscores" WHERE (gamemode = "b") ORDER...
2011-12-07T12:21:08+00:00 app[web.1]:                                                              ^
2011-12-07T12:21:08+00:00 app[web.1]: : SELECT  "highscores".* FROM "highscores" WHERE (gamemode = "b") ORDER BY points DESC LIMIT 100): 2

The Problem is where("gamemode = \"b\"")

So what is the correct statement and why does it not work on heroku this was ? thx

1
  • 1
    Heroku uses Postgres - you should try to have the same environment in development as in production. For your specific question, a solution would be to write the query like this: @highscore = Highscore.where(:gamemode => "b").order("points DESC").limit(100) Commented Dec 7, 2011 at 13:22

1 Answer 1

5

Postgres allows only single quotes for string literals. See this wiki about migrating from mySQL to Postgres. Holds good for sqlite as well.

Sign up to request clarification or add additional context in comments.

1 Comment

This has solved the problem. Thank you. @eugen Your code sample looks more "clean" than mine. Will refactor the statements

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.