From: | "Joshua D(dot) Drake" <jd(at)commandprompt(dot)com> |
---|---|
To: | Andrew Madu <andrewmadu(at)gmail(dot)com> |
Cc: | rubyonrails-talk(at)googlegroups(dot)com, pgsql-general(at)postgresql(dot)org |
Subject: | Re: PostgreSQL primary (sequence) key issue (Ruby/Rails) |
Date: | 2007-03-01 19:23:03 |
Message-ID: | 45E72817.90607@commandprompt.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
> On 01/03/07, Andrew Madu < andrewmadu(at)gmail(dot)com> wrote:
>>
>> Hi Dave,
>> my apologies for contacting you off list but i'm having a spot of bother
>> with postgreSQL sequence setup in rails. In addition to what is mentioned
>> below, I have place the following line of code in my
The definition of primary key explicitly states that it can't be null.
You are trying to pass a null to user_id which won't work.
Joshua D. Drkae
>> environment.rbdocument:
>>
>> # Include your application configuration below
>> ActiveRecord::Base.pluralize_table_names = false
>> ActiveRecord::Base.set_sequence_name
>>
>> What I am overlooking here?
>>
>> --
>> Regards
>>
>> Andrew
>>
>> ---------- Forwarded message ----------
>> From: Andrew Madu < andrewmadu(at)gmail(dot)com>
>> Date: 01-Mar-2007 15:28
>> Subject: Re: PostgreSQL primary (sequence) key issue
>> To: rubyonrails-talk(at)googlegroups(dot)com
>>
>> Hi,
>> I've followed the example given here:
>>
>> http://ar.rubyonrails.com/classes/ActiveRecord/Base.html#M000367
>>
>> and implemented set_sequence_name "seq_name" in my class. When I try to
>> update the user table with a new row from:
>>
>> http://localhost:3000/usertbl/new
>>
>> I get the following error message:
>>
>> RuntimeError: ERROR C23502 Mnull value in column "user_id"
>> violates not-null constraint
>>
>>
>> FexecMain.c L1795 RExecConstraints: INSERT INTO usertbl
>>
>>
>> What am I overlooking here?
>>
>> Also coud possibly give me any clues on how to setup an 'assigned'
>> primary
>> key in an ActiveRecord class?
>>
>> --
>> Regards
>>
>> Andrew
>>
>> On 01/03/07, Andrew Madu <andrewmadu(at)gmail(dot)com> wrote:
>> >
>> > Hi,
>> > I have a sequence set up on one of my tables called seq_user_mytable. I
>> > tried the following with no joy:
>> >
>> > set_primary_key "user_id", :sequence => "seq_user_mytable" and:
>> >
>> > ActiveRecord:: Base.seq_user_mytable
>> >
>> > again with no joy. How do I implement a sequence in Rails/ActiveRecord?
>> >
>> > --
>> > Regards
>> >
>> > Andrew
>> >
>>
>>
>
--
=== The PostgreSQL Company: Command Prompt, Inc. ===
Sales/Support: +1.503.667.4564 || 24x7/Emergency: +1.800.492.2240
Providing the most comprehensive PostgreSQL solutions since 1997
http://www.commandprompt.com/
Donate to the PostgreSQL Project: http://www.postgresql.org/about/donate
PostgreSQL Replication: http://www.commandprompt.com/products/
From | Date | Subject | |
---|---|---|---|
Next Message | Russ Brown | 2007-03-01 19:51:30 | Re: PostgreSQL primary (sequence) key issue (Ruby/Rails) |
Previous Message | Andrew Madu | 2007-03-01 19:15:24 | PostgreSQL primary (sequence) key issue (Ruby/Rails) |