0

I am trying to run this very simple query

unless ram.blank?
      list = list.where(['numRam >= ?', ram])
end

it works perfectly on my local server where I am using mysql as my database, but it gives me this error in production where I use psql

2017-05-07 11:13:57 UTC ERROR:  column "numram" does not exist at character 68
2017-05-07 11:13:57 UTC STATEMENT:  SELECT COUNT(*) FROM "mobiles" WHERE "mobiles"."visible" = $1 AND (numRam >= '5')

Apparently, it changed numRam to numram which doesn't exist in my database. Is there any solution?

Cœur
  • 37,241
  • 25
  • 195
  • 267
amronrails
  • 100
  • 13

1 Answers1

1

Try this trick:

unless ram.blank?
  list = list.where(['"numRam" >=?', ram])
end
asvetly
  • 1,739
  • 16
  • 17
  • Here is the new error 2017-05-07 11:51:25 UTC ERROR: column "numRam >= '1'" does not exist at character 68 2017-05-07 11:51:25 UTC STATEMENT: SELECT COUNT(*) FROM "mobiles" WHERE "mobiles"."visible" = $1 AND ("numRam >= '1'") – amronrails May 07 '17 at 11:55
  • 2
    Shouldn't it be `'"numRam" >=?'` – Eyeslandic May 07 '17 at 11:58
  • yes `'"numRam" >=?'` solved the issue on psql. However, it isn't functioning anymore on mysql which is fine. My advice is not to use camelcase in psql and try to use the same db in development and production. – amronrails May 07 '17 at 12:15
  • Definitely use the same db in dev and prod, anything else is a constant source of frustration. Can't you change your column name however in production to get around this hack? – Eyeslandic May 07 '17 at 12:17