lundi 14 novembre 2016

PG::NotNullViolation: ERROR: null value in column "id" violates not-null constraint

I am working on ruby 2.3.1 and rails 3.2.1. I want to create new row of record in PostgreSQL db. I have created the database table with two column and primary key id and other column which accept string.

def new_name
  label_name = LabelName.new(:id =>1, :label_name =>'testing' )
  label_name.save()
end 

If I pass the value of id, records get created otherwise I am getting the following error

PG::NotNullViolation: ERROR: null value in column "id" violates not-null constraint.

When I tried to create the record manually in PostgreSQL DB also I am getting the same error.

Please help on how to solve this error.

Thanks

Aucun commentaire:

Enregistrer un commentaire