gregbell/active_admin — Issue #1094: Postgres type comparison error when rendering comments
Author: chrp
Created: 2012-03-01 03:15:37+00:00
State: open

Using postresql database driver I ran into following error when calling any show action in my Rails application:

Showing /Users/chrpes/.rvm/gems/ruby-1.9.2-p290/gems/activeadmin-0.4.2/app/views/active_admin/resource/show.html.arb where line #1 raised:

```
PG::Error: ERROR: operator does not exist: character varying = integer
LINE 1: ...mpaign' AND "active_admin_comments"."resource_id" = 3 AND "a...
^
HINT: No operator matches the given name and argument type(s). You might need to add explicit type casts.
: SELECT COUNT(*) FROM "active_admin_comments" WHERE "active_admin_comments"."resource_type" = 'Campaign' AND "active_admin_comments"."resource_id" = 3 AND "active_admin_comments"."namespace" = 'admin'
```

The reason for the error is `"active_admin_comments"."resource_id" = 3` where the `resource_id` is defined as a `character varying(255)` and compared to an int which Postgres doesn't like.

The error originates in: `ActiveAdmin::Comment.find_for_resource_in_namespace`