Reputation: 1123
So, I setup a staging, and develop branch and now I'm getting this error when registering a new user locally:
PG::Error: ERROR: null value in column "uid" violates
not-null constraint DETAIL: Failing row contains
(7, [email protected], $2a$10$WfiHKzYq4ovZtZoVAB.fRertuOSWezZYBw.RxkSqfBK89WbzcYxDK,
null, null, null, 0, null, null, null, null,
2013-08-13 07:20:13.484617, 2013-08-13 07:20:13.484617,
null, null, null, null). : INSERT INTO "users"
("created_at", "email", "encrypted_password", "updated_at")
VALUES ($1, $2, $3, $4) RETURNING "uid"
schema.rb snippit
create_table "users", id: false, force: true do |t|
t.integer "id", null: false
t.string "email", default: ""
t.string "encrypted_password", default: ""
t.string "reset_password_token"
t.datetime "reset_password_sent_at"
t.datetime "remember_created_at"
t.integer "sign_in_count", default: 0
t.datetime "current_sign_in_at"
t.datetime "last_sign_in_at"
t.string "current_sign_in_ip"
t.string "last_sign_in_ip"
t.datetime "created_at"
t.datetime "updated_at"
t.boolean "admin"
t.string "provider"
t.string "uid", null: false
t.string "username"
end
add_index "users", ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true, using: :btree
I can't push any new code to production until this is worked out, which is annoying :/
Upvotes: 0
Views: 3508
Reputation: 5097
Your uid
is not-nullable but you aren't giving any values to it. Have your application generate one while you are registering users.
Ruby has a module named Secure Random which can be used to generate uids. It's usage is also pretty easy. Like,
require 'securerandom'
uid = SecureRandom.hex(10)
However, you can use factory girl to initialize your objects. For testing purpose though.
Upvotes: 2
Reputation: 107728
The problem is that your code to create a new user in the database is not defining a uid
value for the row. Your database has constrained that field to disable rows from ever having uid
as null. Therefore, you should either remove this constraint from the database or change your code to pass through a uid
.
Upvotes: 2