views:

34

answers:

1

This page I have been developing for my app has been working fine locally (using sqllite3) but when I push it to Heroku, which uses PostgreSQL I get this error:

NeighborhoodsController# (ActionView::Template::Error) "PGError: ERROR: column \"isupforconsideration\" does not exist\nLINE 1: ... \"photos\" WHERE (neighborhood = 52 AND isUpForCon...\n

From this line of code:

@photos = Photo.where(["neighborhood = ? AND isUpForConsideration = ?", @neighborhood.id, 1])

isUpForConsideration is defiantly part of the Photo column. All my migrations are up to date, and when I pull the db back locally isUpForConsideration is still there, and the app still works locally.

I've also tried:

@photos = @neighborhood.photos(:conditions => {:isUpForConsideration => 1})

and

@photos = @neighborhood.photos.where(["isUpForConsideration = 1"])

Which gives me this error:

NeighborhoodsController# (ActionView::Template::Error) "PGError: ERROR: column \"isupforconsideration\" does not exist\nLINE 1: ...tos\" WHERE (\"photos\".neighborhood = 52) AND (isUpForCon...\n

Any idea what I could be doing wrong?

+1  A: 

Your problem is that table and column names are case sensitive in PostgreSQL. This is normally hidden by automatically converting these to all-lowercase when making queries (hence why you see the error message reporting "isupforconsideration"), but if you managed to dodge that conversion on creation (by double quoting the name, like Rails does for you when you create a table), you'll see this weirdness. You need to enclose "isUpForConsideration" in double quotes when using it in a WHERE clause to fix this.

e.g.

@photos = @neighborhood.photos.where(["\"isUpForConsideration\" = 1"])
Conspicuous Compiler