M
M
Max2015-10-20 19:41:59
Ruby on Rails
Max, 2015-10-20 19:41:59

How to add a new field to the database?

Hello, I forgot to add the user_id field when creating a scaffold for products. And now, after connecting and setting up the devise gem, I can't add a new product to the database.
Created a migration

rails generate migration AddPartNumberToProducts user_id:integer
rake db:migrate

Tell me what to do next? Throws an error
SQLite3::ConstraintException: UNIQUE constraint failed: products.email: INSERT INTO "products" ("title", "description", "number", "price", "user_id", "created_at", "updated_at") VALUES (?, ?, ?, ?, ?, ?, ?)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
TyzhSysAdmin, 2015-10-20
@maxprof

Sqlite tells you that the email field in the products table is not unique, but it should be.
Yes, not so - The value of the email field in the created record is not unique, but it should be!

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question