I'm making an EC site with Rails.
The following error message occurred when trying to edit a column in the user table.
** ActiveRecord :: RecordNotUnique in RailsAdmin :: MainController # edit ** SQLite3 :: ConstraintException: UNIQUE constraint failed: users.unlock_token: UPDATE "users" SET "current_sign_in_at" =?, "Last_sign_in_at" =?, "Confirmed_at" =?, "Confirmation_sent_at" =?, "Unconfirmed_email" =?, "Unlock_token "=?," provider "=?," uid "=?," username "=?," admin_flg "=?," point "=?," updated_at "=? WHERE" users "." id "=?
I can't figure out which area is suspicious, and I don't know which part of the code should be written. .
Can anyone please professor? Thank you. . .
Answer # 1
I think the
unlock_tokencolumn has a unique constraint. If a unique constraint is attached, you cannot create multiple records with the same value.
You can check the list of registered
unlock_tokenwith the following SQL.
SELECT unlock_token FROM users;
You probably already have a record with the value you are trying to update with an UPDATE statement, and that is the cause of the error. For your information.
- css - when linking the entire line, i want to prevent the characters in the line from being underlined
- css - i want to get the url with jquery and make a conditional branch for each parameter
- html - i want to create a background with position:fixed;
- php - i want to use sessionstorage to display the opening animation only at the first access
- html - i want to insert an image in table tag using background-image
- css background-image
- html - responsive web design size
- css in html,css:form tag is no longer reflected if you can understand java a little, please give me instructions
- css - display: flex;is not applied