I have a rails app that was working fine with sqlite but upon switching over to postgre I'm having an issue with this query:
User.find(1).ratings
Querying for just a works, e.g.
User.find(1)
produces
SELECT "users".* FROM "users" WHERE "users"."id" = $1 LIMIT 1 [["id", 1]]
however if I append ratings like so:
User.find(1).ratings
produces
User Load (1.4ms) SELECT "users".* FROM "users" WHERE "users"."id" = $1 LIMIT 1 [["id", 1]]
Rating Load (0.9ms) SELECT "ratings".* FROM "ratings" WHERE "ratings"."user_id" = 1
PG::Error: ERROR: operator does not exist: character varying = integer
LINE 1: ...CT "ratings".* FROM "ratings" WHERE "ratings"."user_id" = 1
^
HINT: No operator matches the given name and argument type(s). You might need to add explicit type casts.
: SELECT "ratings".* FROM "ratings" WHERE "ratings"."user_id" = 1
ActiveRecord::StatementInvalid: PG::Error: ERROR: operator does not exist: character varying = integer
LINE 1: ...CT "ratings".* FROM "ratings" WHERE "ratings"."user_id" = 1
^
Whether a pass the :id as an int or string it still produces the above error. The models are set up so :ratings belongs_to User which has_many :ratings. Any ideas? Thanks in advance.
Versions: Rails 3.1.1, Ruby 1.9.2, devise 1.5.1
user_idfield/foreign key on theratingstable definitely an integer?