Home>
What you don't understand
I am creating a micropost in the rails tutorial exercise, but when I go to root_url
StandardError
An error has occurred, this and all later migrations canceled: SQLite3 :: SQLException: duplicate column name: reset_sent_at
I get an error.
I know that User's reset_sent_at column is duplicated, but I'm not sure where and how it is duplicated. I would be grateful if anyone could give me some advice on how to resolve this error.
# app/models/user.rb
class User</pre>
<pre><code># app/controllers/password_resets_controller.rb
class PasswordResetsController</pre>
<pre><code># config/routes.rb
Rails.application.routes.draw do
get'password_resets/new'
get'password_resets/edit'
root'static_pages # home'
get'/ help', to:'static_pages # help'
get'/ about', to:'static_pages # about'
get'/ contact', to:'static_pages # contact'
get'/ signup', to:'users # new'
get'/ login', to:'sessions # new'
post'/ login', to:'sessions # create'
delete'/ logout', to:'sessions # destroy'
resources: users
resources: account_activations, only: [: edit]
resources: password_resets, only: [: new,: create,: edit,: update]
end
# app/mailers/user_mailer.rb
class UserMailer</pre>
<pre><code># 20201223140935_add_reset_to_users.rb
class AddResetToUsers</pre>
<pre><code># 20201223141905_add_reset_sent_at_to_users.rb
class AddResetSentAtToUsers</pre>
<pre><code># db/schema.rb
ActiveRecord :: Schema.define (version: 2020_12_26_033956) do
create_table "microposts", force:: cascade do | t |
t.text "content"
t.integer "user_id", null: false
t.datetime "created_at", precision: 6, null: false
t.datetime "updated_at", precision: 6, null: false
t.index ["user_id", "created_at"],
name: "index_microposts_on_user_id_and_created_at"
t.index ["user_id"],
name: "index_microposts_on_user_id"
end
create_table "users", force:: cascade do | t |
t.string "name"
t.string "email"
t.datetime "created_at", precision: 6, null: false
t.datetime "updated_at", precision: 6, null: falset.string "password_digest"
t.string "remember_digest"
t.boolean "admin", default: false
t.string "activation_digest"
t.boolean "activated", default: false
t.datetime "activated_at"
t.string "reset_digest"
t.datetime "reset_sent_at"
t.index ["email"],
name: "index_users_on_email", unique: true
end
add_foreign_key "microposts", "users"
end
What I tried
rails db: test: prepare
rails db: migrate RAILS_ENV = development
rails db: migrate: reset
20201223140935_add_reset_to_users.rb
20201223141905_add_reset_sent_at_to_users.rb
db/schema.rb
Try commenting out the reset_sent_at part of
=>I was able to access root_url, but an error occurred when transitioning to the password reset screen.
CentOS8
#Gemfile
source'https://rubygems.org'
git_source (: github) {| repo | "https://github.com/#{repo}.git"}
gem'rails', '6.0.3'
gem'bcrypt', '3.1.13'
gem'faker', '2.1.2'
gem'will_paginate', '3.1.8'
gem'bootstrap-will_paginate', '1.0.0'
gem'bootstrap-sass', '3.4.1'
gem'puma', '4.3.6'
gem'sass-rails', '5.1.0'
gem'webpacker', '4.0.7'
gem'turbolinks', '5.2.0'
gem'jbuilder', '2.9.1'
gem'bootsnap', '1.4.5', require: false
group: development,: test do
gem'sqlite3', '1.4.1'
gem'byebug', '11 .0.1', platforms: [: mri,: mingw,: x64_mingw]
end
group: development do
gem'web-console', '4.0.1'
gem'listen', '3.1.5'
gem'spring', '2.1.0'
gem'spring-watcher-listen', '2.0.1'
end
group: test do
gem'capybara', '3.28.0'
gem'selenium-webdriver', '3.142.4'
gem'webdrivers', '4.1.2'
gem'rails-controller-testing', '1.0.4'
gem'minitest', '5.11.3'
gem'minitest-reporters', '1.3.8'
gem'guard', '2.16.2'
gem'guard-minitest', '2.4.6'
end
group: production do
gem'pg', '1.1.4'
end
# On Windows you need to include a tzinfo-data gem for timezone information
gem'tzinfo-data', platforms: [: mingw,: mswin,: x64_mingw,: jruby]
-
Answer # 1
Related articles
- ruby on rails - [rails 6] password column contents are not displayed in active_admin
- ruby - i added a rails column, but i can't associate it with the user table
- ruby on rails - [rails] the initial image of the icon for the user is not displayed
- ruby on rails 6 - i want the posted prototype to be displayed on the top page
- ruby on rails - the graph is not displayed well in the app using rails a 0 will be entered in the date when no data is entered,
- ruby on rails - i want to avoid displaying duplicate data for each shop
- ruby on rails - the image is not displayed on the article details screen sprockets :: rails :: helper :: assetnotfound
- [ruby on rails] the page is not displayed after connecting to the server on aws cloud9
- ruby - partial template is not displayed (rails)
- ruby - rails i want to group the same column, link the column name, and click to display all records in that column, but i get a
- ruby on rails 5 - f the value sent in hidden_field is not displayed
- ruby - ambiguous column name error is displayed
- ruby on rails - when i make a message, i want the date to be displayed, but i get "undefined method` strftime' for nil: nil
- ruby on rails 5 - transaction exception handling doesn't work
- about validation of ruby on rails
- ruby on rails - i get an error in a program that changes over time
- ruby on rails - i want to sort the search results
- ruby - [rails 5] i want to send an email to a specific user using action mailer
- ruby on rails - i want to solve the problem that scss is not applied after modifying the scss file with rails
Related questions
- ruby - i started the server in rails s but can't open it
- ruby - sass :: syntaxerror on rails s
- ruby - error when bundle install gem :: ext :: builderror: error: failed to build gem native extension
- ruby - rmagick cannot be installed
- ruby - when deploying on capistrano, i get the error "access denied for user'ec2-user' @'localhost' (using password: no)&qu
- ruby - i get an error when testing rspec instance variables
- ruby - about embedding rails videos
- ruby - how to implement the edit/update function of multiple tables when using form object in rails
- ruby - all rails gems are not installed
I don't know if I really need to fix this, but I've found at least one duplicate that clearly seems to be a problem.
This is likely to be a problem as we are creating columns with the same column name twice for the same table.
However, in this case, it seems that an error will occur at the time of db: migrate, not during the operation of the application .... I hope it will give you some hints.