PGError: ERROR: column "id" does not exist

66 views
Skip to first unread message

rachel anne

unread,
Feb 25, 2009, 4:16:06 AM2/25/09
to Rails Authorization Plugin
hi

i need help with this :) i'm not sure how to do it as i'm pretty new
to rails. i followed what was written in the test db migration file
which has the id for roles_user table set to false. i believe that is
the problem. but i'm sure you wouldn't have set it up like that if it
won't work, right? so question is, what could possibly be wrong with
my code? i added acts_as_authorized_user and acts_as_authorizable
in my user model and acts_as_authorizable in my other model.

when i do:

@object.accepts_role('tester', current_user)

i get this error:

PGError: ERROR: column "id" does not exist
LINE 1: ...248664', 1, 23, '2009-02-25 15:44:49.248664') RETURNING
"id"
^
: INSERT INTO "roles_users" ("updated_at", "role_id", "person_id",
"created_at") VALUES('2009-02-25 15:44:49.248664', 1, 23, '2009-02-25
15:44:49.248664') RETURNING "id"

i'm using PostGreSQL for my database and have rails 2.2.2 on my system


p.s.
i'm not sure if this is double posted as i can't see my previous post..

steph

unread,
Apr 16, 2009, 4:39:19 PM4/16/09
to Rails Authorization Plugin
I have the same problem PostgreSQL 8.3.7, rails 2.3.2. The code in
the postgres adapter has changed from 2.1.0 (previous version of Rails
where this worked) -- the new code checks to see if insert with
'returning id' is available and if so uses it. That returns true if
postgresql_version is >= 80200. That seems to be where things choke
for me, but I don't know how it decides that roles_users has a primary
key of 'id' when it doesn't.

Ian

unread,
May 11, 2009, 6:18:09 PM5/11/09
to Rails Authorization Plugin
Hi,

I managed to solve this by specifiying user_id and role_id as primary
keys for the RolesUser controller since there is no id column for the
roles_user table.
First, you need to install the compositekeys gem (http://
compositekeys.rubyforge.org/). After that, add this to roles_user.rb:
set_primary_keys :user_id, :role_id

Then it should be working.

/ian

On Apr 16, 10:39 pm, steph <steph.brid...@gmail.com> wrote:
> On Feb 25, 4:16 am, rachel anne <rachelannenava...@gmail.com> wrote:
>
>
>
> > hi
>
> > i need help with this :) i'm not sure how to do it as i'm pretty new
> > to rails. i followed what was written in the test db migration file
> > which has the id for roles_user table set to false. i believe that is
> > the problem. but i'm sure you wouldn't have set it up like that if it
> > won't work, right? so question is, what could possibly be wrong with
> > my code? i added   acts_as_authorized_user and   acts_as_authorizable
> > in my user model and acts_as_authorizable in my other model.
>
> > when i do:
>
> > @object.accepts_role('tester', current_user)
>
> > i get this error:
>
> > PGError: ERROR:  column "id" does not exist
> > LINE 1: ...248664', 1, 23, '2009-02-25 15:44:49.248664') RETURNING
> > "id"
> >                                                                    ^
> > : INSERT INTO "roles_users" ("updated_at", "role_id", "person_id",
> > "created_at") VALUES('2009-02-25 15:44:49.248664', 1, 23, '2009-02-25
> > 15:44:49.248664') RETURNING "id"
>
> > i'm usingPostGreSQLfor my database and have rails 2.2.2 on my system
>
> I have the same problemPostgreSQL8.3.7, rails 2.3.2.  The code in
Reply all
Reply to author
Forward
0 new messages