
deviseを使い、userのマイグレーションファイルをデータベースに反映させ、userテーブルを作成しようとしたのですがエラーが発生して反映できません。
$ rails db:migrate /home/ubuntu/environment/tsunageru/app/models/user.rb:20:in `<class:User>': uninitialized constant User::ImageUploader (NameError) from /home/ubuntu/environment/tsunageru/app/models/user.rb:3:in `<main>' from /home/ubuntu/.rvm/gems/ruby-3.0.0/gems/bootsnap-1.13.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require' from /home/ubuntu/.rvm/gems/ruby-3.0.0/gems/bootsnap-1.13.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require' from /home/ubuntu/.rvm/gems/ruby-3.0.0/gems/zeitwerk-2.6.0/lib/zeitwerk/kernel.rb:27:in `require' from /home/ubuntu/.rvm/gems/ruby-3.0.0/gems/activesupport-6.1.7/lib/active_support/inflector/methods.rb:274:in `const_get' from /home/ubuntu/.rvm/gems/ruby-3.0.0/gems/activesupport-6.1.7/lib/active_support/inflector/methods.rb:274:in `constantize' from /home/ubuntu/.rvm/gems/ruby-3.0.0/gems/activesupport-6.1.7/lib/active_support/dependencies/zeitwerk_integration.rb:19:in `constantize' from /home/ubuntu/.rvm/gems/ruby-3.0.0/gems/devise-4.8.1/lib/devise.rb:318:in `get' from /home/ubuntu/.rvm/gems/ruby-3.0.0/gems/devise-4.8.1/lib/devise/mapping.rb:83:in `to' from /home/ubuntu/.rvm/gems/ruby-3.0.0/gems/devise-4.8.1/lib/devise/mapping.rb:78:in `modules' from /home/ubuntu/.rvm/gems/ruby-3.0.0/gems/devise-4.8.1/lib/devise/mapping.rb:95:in `routes' from /home/ubuntu/.rvm/gems/ruby-3.0.0/gems/devise-4.8.1/lib/devise/mapping.rb:162:in `default_used_route' from /home/ubuntu/.rvm/gems/ruby-3.0.0/gems/devise-4.8.1/lib/devise/mapping.rb:72:in `initialize' from /home/ubuntu/.rvm/gems/ruby-3.0.0/gems/devise-4.8.1/lib/devise.rb:354:in `new' from /home/ubuntu/.rvm/gems/ruby-3.0.0/gems/devise-4.8.1/lib/devise.rb:354:in `add_mapping' from /home/ubuntu/.rvm/gems/ruby-3.0.0/gems/devise-4.8.1/lib/devise/rails/routes.rb:243:in `block in devise_for' from /home/ubuntu/.rvm/gems/ruby-3.0.0/gems/devise-4.8.1/lib/devise/rails/routes.rb:242:in `each' from /home/ubuntu/.rvm/gems/ruby-3.0.0/gems/devise-4.8.1/lib/devise/rails/routes.rb:242:in `devise_for' from /home/ubuntu/environment/tsunageru/config/routes.rb:2:in `block in <main>' from /home/ubuntu/.rvm/gems/ruby-3.0.0/gems/actionpack-6.1.7/lib/action_dispatch/routing/route_set.rb:427:in `instance_exec' from /home/ubuntu/.rvm/gems/ruby-3.0.0/gems/actionpack-6.1.7/lib/action_dispatch/routing/route_set.rb:427:in `eval_block' from /home/ubuntu/.rvm/gems/ruby-3.0.0/gems/actionpack-6.1.7/lib/action_dispatch/routing/route_set.rb:409:in `draw' from /home/ubuntu/environment/tsunageru/config/routes.rb:1:in `<main>' from /home/ubuntu/.rvm/gems/ruby-3.0.0/gems/railties-6.1.7/lib/rails/application/routes_reloader.rb:47:in `load' from /home/ubuntu/.rvm/gems/ruby-3.0.0/gems/railties-6.1.7/lib/rails/application/routes_reloader.rb:47:in `block in load_paths' from /home/ubuntu/.rvm/gems/ruby-3.0.0/gems/railties-6.1.7/lib/rails/application/routes_reloader.rb:47:in `each' from /home/ubuntu/.rvm/gems/ruby-3.0.0/gems/railties-6.1.7/lib/rails/application/routes_reloader.rb:47:in `load_paths' from /home/ubuntu/.rvm/gems/ruby-3.0.0/gems/railties-6.1.7/lib/rails/application/routes_reloader.rb:21:in `reload!' from /home/ubuntu/.rvm/gems/ruby-3.0.0/gems/railties-6.1.7/lib/rails/application/routes_reloader.rb:35:in `block in updater' from /home/ubuntu/.rvm/gems/ruby-3.0.0/gems/activesupport-6.1.7/lib/active_support/file_update_checker.rb:83:in `execute' from /home/ubuntu/.rvm/gems/ruby-3.0.0/gems/railties-6.1.7/lib/rails/application/routes_reloader.rb:10:in `execute' from /home/ubuntu/.rvm/gems/ruby-3.0.0/gems/railties-6.1.7/lib/rails/application/finisher.rb:195:in `block in <module:Finisher>' from /home/ubuntu/.rvm/gems/ruby-3.0.0/gems/railties-6.1.7/lib/rails/initializable.rb:32:in `instance_exec' from /home/ubuntu/.rvm/gems/ruby-3.0.0/gems/railties-6.1.7/lib/rails/initializable.rb:32:in `run' from /home/ubuntu/.rvm/gems/ruby-3.0.0/gems/railties-6.1.7/lib/rails/initializable.rb:61:in `block in run_initializers' from /home/ubuntu/.rvm/rubies/ruby-3.0.0/lib/ruby/3.0.0/tsort.rb:228:in `block in tsort_each' from /home/ubuntu/.rvm/rubies/ruby-3.0.0/lib/ruby/3.0.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component' from /home/ubuntu/.rvm/rubies/ruby-3.0.0/lib/ruby/3.0.0/tsort.rb:431:in `each_strongly_connected_component_from' from /home/ubuntu/.rvm/rubies/ruby-3.0.0/lib/ruby/3.0.0/tsort.rb:349:in `block in each_strongly_connected_component' from /home/ubuntu/.rvm/rubies/ruby-3.0.0/lib/ruby/3.0.0/tsort.rb:347:in `each' from /home/ubuntu/.rvm/rubies/ruby-3.0.0/lib/ruby/3.0.0/tsort.rb:347:in `call' from /home/ubuntu/.rvm/rubies/ruby-3.0.0/lib/ruby/3.0.0/tsort.rb:347:in `each_strongly_connected_component' from /home/ubuntu/.rvm/rubies/ruby-3.0.0/lib/ruby/3.0.0/tsort.rb:226:in `tsort_each' from /home/ubuntu/.rvm/rubies/ruby-3.0.0/lib/ruby/3.0.0/tsort.rb:205:in `tsort_each' from /home/ubuntu/.rvm/gems/ruby-3.0.0/gems/railties-6.1.7/lib/rails/initializable.rb:60:in `run_initializers' from /home/ubuntu/.rvm/gems/ruby-3.0.0/gems/railties-6.1.7/lib/rails/application.rb:391:in `initialize!' from /home/ubuntu/environment/tsunageru/config/environment.rb:5:in `<main>' from /home/ubuntu/.rvm/gems/ruby-3.0.0/gems/bootsnap-1.13.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require' from /home/ubuntu/.rvm/gems/ruby-3.0.0/gems/bootsnap-1.13.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require' from /home/ubuntu/.rvm/gems/ruby-3.0.0/gems/zeitwerk-2.6.0/lib/zeitwerk/kernel.rb:35:in `require' from /home/ubuntu/.rvm/gems/ruby-3.0.0/gems/activesupport-6.1.7/lib/active_support/dependencies.rb:332:in `block in require' from /home/ubuntu/.rvm/gems/ruby-3.0.0/gems/activesupport-6.1.7/lib/active_support/dependencies.rb:299:in `load_dependency' from /home/ubuntu/.rvm/gems/ruby-3.0.0/gems/activesupport-6.1.7/lib/active_support/dependencies.rb:332:in `require' from /home/ubuntu/.rvm/gems/ruby-3.0.0/gems/spring-4.1.0/lib/spring/application.rb:107:in `preload' from /home/ubuntu/.rvm/gems/ruby-3.0.0/gems/spring-4.1.0/lib/spring/application.rb:166:in `serve' from /home/ubuntu/.rvm/gems/ruby-3.0.0/gems/spring-4.1.0/lib/spring/application.rb:148:in `block in run' from /home/ubuntu/.rvm/gems/ruby-3.0.0/gems/spring-4.1.0/lib/spring/application.rb:142:in `loop' from /home/ubuntu/.rvm/gems/ruby-3.0.0/gems/spring-4.1.0/lib/spring/application.rb:142:in `run' from /home/ubuntu/.rvm/gems/ruby-3.0.0/gems/spring-4.1.0/lib/spring/application/boot.rb:19:in `<top (required)>' from <internal:/home/ubuntu/.rvm/rubies/ruby-3.0.0/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in `require' from <internal:/home/ubuntu/.rvm/rubies/ruby-3.0.0/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in `require' from -e:1:in `<main>'
ちなみに一度やり直してデータベースを一度削除して同じ名前のプロジェクトを作成し、
データベースも作り直したのですが、それが影響しているのでしょうか?
modelとマイグレーションファイルは文字数が超えてしまったため追記のところに載せます。
拙い質問ですが、知っている方がいましたらアドバイスを頂戴したく、思っております。

文字数が超えてしまったので、こちらに追記させていただきます。
userマイグレーションファイる
```
# frozen_string_literal: true
class DeviseCreateUsers < ActiveRecord::Migration[6.1]
def change
create_table :users do |t|
## Database authenticatable
t.string :email, null: false, default: ""
t.string :encrypted_password, null: false, default: ""
#ユーザープロフィール含むカラム
t.string :name, null: false
t.string :furiganaName, null: false
t.string :password_digest, null: false, default: ""
t.string :telephone_number, null: false
t.string :post_code, null:false
t.string :address, null: false
t.string :self_inroduction
t.string :image
## Recoverable
t.string :reset_password_token
t.datetime :reset_password_sent_at
## Rememberable
t.datetime :remember_created_at
## Trackable
# t.integer :sign_in_count, default: 0, null: false
# t.datetime :current_sign_in_at
# t.datetime :last_sign_in_at
# t.string :current_sign_in_ip
# t.string :last_sign_in_ip
## Confirmable
# t.string :confirmation_token
# t.datetime :confirmed_at
# t.datetime :confirmation_sent_at
# t.string :unconfirmed_email # Only if using reconfirmable
## Lockable
# t.integer :failed_attempts, default: 0, null: false # Only if lock strategy is :failed_attempts
# t.string :unlock_token # Only if unlock strategy is :email or :both
# t.datetime :locked_at
t.timestamps null: false
end
```
userモデル
```
class User < ApplicationRecord
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable, :trackable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :validatable
validates :name, presence: true, length: { maximum: 50 }
validates :email, presence: true, length: { maximum: 255 },
format: { with: /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i },
uniqueness: { case_sensitive: false }
validates :furiganaName, presence: true, length: { maximum: 100 },
format: { with: /\A[ぁ-ん]+\z/u }
validates :telephone_number, numericality: { only_integer: true }, length: { maximum:11 },
format: { with: /\A[0-9]+\z/ }
validates :post_code, presence: true, format:{with: /\A\d{3}[-]?\d{4}\z/}
validates :password, presence: true, length: { minimum: 6, maximum: 10 }
validates :self_introduction, presence: false, length: { maximum: 1000 }
mount_uploader :image, ImageUploader
end
```

回答1件
あなたの回答
tips
プレビュー