Forum: Ruby on Rails PostgreSQL primary (sequence) key issue (Ruby/Rails)

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
420aefb1d5de8150ec86fb240196e1be?d=identicon&s=25 Andrew Madu (Guest)
on 2007-03-01 20:20
(Received via mailing list)
Hi Guys,
I'm completely stumped with this one!

I've included ActiveRecord::Base.set_sequence_name in my environment.rb,
in my user.rb I've placed the following code:

class Usertbl < ActiveRecord::Base
    set_primary_key "user_id"
    set_sequence_name "seq_user_mytable"
    validates_uniqueness_of :userpassword, :username, :scope => :user_id

From http://localhost:3000/usertbl/new I then attempt to enter a new a
record and receive the following error message:

RuntimeError: ERROR  C23502  Mnull value in column "user_id" violates
not-null constraint

FexecMain.c  L1795  RExecConstraints: INSERT INTO usertbl

Oh my head hurts!!


This topic is locked and can not be replied to.