質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
Ruby

Rubyはプログラミング言語のひとつで、オープンソース、オブジェクト指向のプログラミング開発に対応しています。

Ruby on Rails

Ruby on Railsは、オープンソースのWebアプリケーションフレームワークです。「同じことを繰り返さない」というRailsの基本理念のもと、他のフレームワークより少ないコードで簡単に開発できるよう設計されています。

Q&A

解決済

1回答

560閲覧

deviseを使ったuserの新規登録ができない

退会済みユーザー

退会済みユーザー

総合スコア0

Ruby

Rubyはプログラミング言語のひとつで、オープンソース、オブジェクト指向のプログラミング開発に対応しています。

Ruby on Rails

Ruby on Railsは、オープンソースのWebアプリケーションフレームワークです。「同じことを繰り返さない」というRailsの基本理念のもと、他のフレームワークより少ないコードで簡単に開発できるよう設計されています。

0グッド

0クリップ

投稿2022/09/27 01:25

・困っている点
deviseを使いuserの新規登録を行おうとしたのですが、エラーが発生しました。
エラーを見る限り、RegistrationsControllerからエラーが発生しているのはわかるのですが、
発生しているコードの箇所が分かりません。

・エラーメッセージ

NoMethodError in Users::RegistrationsController#create undefined method `self_introduction' for #<User:0x00007f3218057fc0> Did you mean? self_inroduction self_inroduction? self_inroduction= self_inroduction_was Extracted source (around line #469): 467 468 469 470 471 472 else match = matched_attribute_method(method.to_s) match ? attribute_missing(match, *args, &block) : super end end ruby2_keywords(:method_missing) if respond_to?(:ruby2_keywords, true) Rails.root: /home/ubuntu/environment/tsunageru Application Trace | Framework Trace | Full Trace activemodel (6.1.7) lib/active_model/attribute_methods.rb:469:in `method_missing' activemodel (6.1.7) lib/active_model/validator.rb:150:in `block in validate' activemodel (6.1.7) lib/active_model/validator.rb:149:in `each' activemodel (6.1.7) lib/active_model/validator.rb:149:in `validate' activesupport (6.1.7) lib/active_support/callbacks.rb:427:in `block in make_lambda' activesupport (6.1.7) lib/active_support/callbacks.rb:198:in `block (2 levels) in halting' activesupport (6.1.7) lib/active_support/callbacks.rb:604:in `block (2 levels) in default_terminator' activesupport (6.1.7) lib/active_support/callbacks.rb:603:in `catch' activesupport (6.1.7) lib/active_support/callbacks.rb:603:in `block in default_terminator' activesupport (6.1.7) lib/active_support/callbacks.rb:199:in `block in halting' activesupport (6.1.7) lib/active_support/callbacks.rb:512:in `block in invoke_before' activesupport (6.1.7) lib/active_support/callbacks.rb:512:in `each' activesupport (6.1.7) lib/active_support/callbacks.rb:512:in `invoke_before' activesupport (6.1.7) lib/active_support/callbacks.rb:105:in `run_callbacks' activesupport (6.1.7) lib/active_support/callbacks.rb:824:in `_run_validate_callbacks' activemodel (6.1.7) lib/active_model/validations.rb:406:in `run_validations!' activemodel (6.1.7) lib/active_model/validations/callbacks.rb:117:in `block in run_validations!' activesupport (6.1.7) lib/active_support/callbacks.rb:106:in `run_callbacks' activesupport (6.1.7) lib/active_support/callbacks.rb:824:in `_run_validation_callbacks' activemodel (6.1.7) lib/active_model/validations/callbacks.rb:117:in `run_validations!' activemodel (6.1.7) lib/active_model/validations.rb:337:in `valid?' activerecord (6.1.7) lib/active_record/validations.rb:68:in `valid?' activerecord (6.1.7) lib/active_record/validations.rb:84:in `perform_validations' activerecord (6.1.7) lib/active_record/validations.rb:47:in `save' activerecord (6.1.7) lib/active_record/transactions.rb:298:in `block in save' activerecord (6.1.7) lib/active_record/transactions.rb:354:in `block in with_transaction_returning_status' activerecord (6.1.7) lib/active_record/connection_adapters/abstract/database_statements.rb:320:in `block in transaction' activerecord (6.1.7) lib/active_record/connection_adapters/abstract/transaction.rb:319:in `block in within_new_transaction' activesupport (6.1.7) lib/active_support/concurrency/load_interlock_aware_monitor.rb:26:in `block (2 levels) in synchronize' activesupport (6.1.7) lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in `handle_interrupt' activesupport (6.1.7) lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in `block in synchronize' activesupport (6.1.7) lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in `handle_interrupt' activesupport (6.1.7) lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in `synchronize' activerecord (6.1.7) lib/active_record/connection_adapters/abstract/transaction.rb:317:in `within_new_transaction' activerecord (6.1.7) lib/active_record/connection_adapters/abstract/database_statements.rb:320:in `transaction' activerecord (6.1.7) lib/active_record/transactions.rb:350:in `with_transaction_returning_status' activerecord (6.1.7) lib/active_record/transactions.rb:298:in `save' activerecord (6.1.7) lib/active_record/suppressor.rb:44:in `save' devise (4.8.1) app/controllers/devise/registrations_controller.rb:19:in `create' actionpack (6.1.7) lib/action_controller/metal/basic_implicit_render.rb:6:in `send_action' actionpack (6.1.7) lib/abstract_controller/base.rb:228:in `process_action' actionpack (6.1.7) lib/action_controller/metal/rendering.rb:30:in `process_action' actionpack (6.1.7) lib/abstract_controller/callbacks.rb:42:in `block in process_action' activesupport (6.1.7) lib/active_support/callbacks.rb:106:in `run_callbacks' actionpack (6.1.7) lib/abstract_controller/callbacks.rb:41:in `process_action' actionpack (6.1.7) lib/action_controller/metal/rescue.rb:22:in `process_action' actionpack (6.1.7) lib/action_controller/metal/instrumentation.rb:34:in `block in process_action' activesupport (6.1.7) lib/active_support/notifications.rb:203:in `block in instrument' activesupport (6.1.7) lib/active_support/notifications/instrumenter.rb:24:in `instrument' activesupport (6.1.7) lib/active_support/notifications.rb:203:in `instrument' actionpack (6.1.7) lib/action_controller/metal/instrumentation.rb:33:in `process_action' actionpack (6.1.7) lib/action_controller/metal/params_wrapper.rb:249:in `process_action' activerecord (6.1.7) lib/active_record/railties/controller_runtime.rb:27:in `process_action' actionpack (6.1.7) lib/abstract_controller/base.rb:165:in `process' actionview (6.1.7) lib/action_view/rendering.rb:39:in `process' actionpack (6.1.7) lib/action_controller/metal.rb:190:in `dispatch' actionpack (6.1.7) lib/action_controller/metal.rb:254:in `dispatch' actionpack (6.1.7) lib/action_dispatch/routing/route_set.rb:50:in `dispatch' actionpack (6.1.7) lib/action_dispatch/routing/route_set.rb:33:in `serve' actionpack (6.1.7) lib/action_dispatch/routing/mapper.rb:19:in `block in <class:Constraints>' actionpack (6.1.7) lib/action_dispatch/routing/mapper.rb:49:in `serve' actionpack (6.1.7) lib/action_dispatch/journey/router.rb:50:in `block in serve' actionpack (6.1.7) lib/action_dispatch/journey/router.rb:32:in `each' actionpack (6.1.7) lib/action_dispatch/journey/router.rb:32:in `serve' actionpack (6.1.7) lib/action_dispatch/routing/route_set.rb:842:in `call' warden (1.2.9) lib/warden/manager.rb:36:in `block in call' warden (1.2.9) lib/warden/manager.rb:34:in `catch' warden (1.2.9) lib/warden/manager.rb:34:in `call' rack (2.2.4) lib/rack/tempfile_reaper.rb:15:in `call' rack (2.2.4) lib/rack/etag.rb:27:in `call' rack (2.2.4) lib/rack/conditional_get.rb:40:in `call' rack (2.2.4) lib/rack/head.rb:12:in `call' actionpack (6.1.7) lib/action_dispatch/http/permissions_policy.rb:22:in `call' actionpack (6.1.7) lib/action_dispatch/http/content_security_policy.rb:19:in `call' rack (2.2.4) lib/rack/session/abstract/id.rb:266:in `context' rack (2.2.4) lib/rack/session/abstract/id.rb:260:in `call' actionpack (6.1.7) lib/action_dispatch/middleware/cookies.rb:689:in `call' activerecord (6.1.7) lib/active_record/migration.rb:601:in `call' actionpack (6.1.7) lib/action_dispatch/middleware/callbacks.rb:27:in `block in call' activesupport (6.1.7) lib/active_support/callbacks.rb:98:in `run_callbacks' actionpack (6.1.7) lib/action_dispatch/middleware/callbacks.rb:26:in `call' actionpack (6.1.7) lib/action_dispatch/middleware/executor.rb:14:in `call' actionpack (6.1.7) lib/action_dispatch/middleware/actionable_exceptions.rb:18:in `call' actionpack (6.1.7) lib/action_dispatch/middleware/debug_exceptions.rb:29:in `call' web-console (4.2.0) lib/web_console/middleware.rb:132:in `call_app' web-console (4.2.0) lib/web_console/middleware.rb:19:in `block in call' web-console (4.2.0) lib/web_console/middleware.rb:17:in `catch' web-console (4.2.0) lib/web_console/middleware.rb:17:in `call' actionpack (6.1.7) lib/action_dispatch/middleware/show_exceptions.rb:33:in `call' railties (6.1.7) lib/rails/rack/logger.rb:37:in `call_app' railties (6.1.7) lib/rails/rack/logger.rb:26:in `block in call' activesupport (6.1.7) lib/active_support/tagged_logging.rb:99:in `block in tagged' activesupport (6.1.7) lib/active_support/tagged_logging.rb:37:in `tagged' activesupport (6.1.7) lib/active_support/tagged_logging.rb:99:in `tagged' railties (6.1.7) lib/rails/rack/logger.rb:26:in `call' sprockets-rails (3.4.2) lib/sprockets/rails/quiet_assets.rb:13:in `call' actionpack (6.1.7) lib/action_dispatch/middleware/remote_ip.rb:81:in `call' actionpack (6.1.7) lib/action_dispatch/middleware/request_id.rb:26:in `call' rack (2.2.4) lib/rack/method_override.rb:24:in `call' rack (2.2.4) lib/rack/runtime.rb:22:in `call' activesupport (6.1.7) lib/active_support/cache/strategy/local_cache_middleware.rb:29:in `call' actionpack (6.1.7) lib/action_dispatch/middleware/executor.rb:14:in `call' actionpack (6.1.7) lib/action_dispatch/middleware/static.rb:24:in `call' rack (2.2.4) lib/rack/sendfile.rb:110:in `call' actionpack (6.1.7) lib/action_dispatch/middleware/host_authorization.rb:142:in `call' webpacker (5.4.3) lib/webpacker/dev_server_proxy.rb:25:in `perform_request' rack-proxy (0.7.4) lib/rack/proxy.rb:78:in `call' railties (6.1.7) lib/rails/engine.rb:539:in `call' puma (5.6.5) lib/puma/configuration.rb:252:in `call' puma (5.6.5) lib/puma/request.rb:77:in `block in handle_request' puma (5.6.5) lib/puma/thread_pool.rb:340:in `with_force_shutdown' puma (5.6.5) lib/puma/request.rb:76:in `handle_request' puma (5.6.5) lib/puma/server.rb:443:in `process_client' puma (5.6.5) lib/puma/thread_pool.rb:147:in `block in spawn_thread' Request Parameters: {"authenticity_token"=>"[FILTERED]", "user"=> {"name"=>"株式会社テスト", "furiganaName"=>"テスト", "email"=>"sgkf0006@sun.cims.jp", "post_code"=>"0000000", "address"=>"東京都渋谷区", "telephone_number"=>"00000000000", "password"=>"[FILTERED]", "password_confirmation"=>"[FILTERED]"}, "commit"=>"登録"} Toggle session dump Toggle env dump Response Headers: None

これ以上、書けないので下に追記させていただきます。

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

退会済みユーザー

退会済みユーザー

2022/09/27 01:26

・RegistrationsController ``` # frozen_string_literal: true class Users::RegistrationsController < Devise::RegistrationsController # before_action :configure_sign_up_params, only: [:create] # before_action :configure_account_update_params, only: [:update] # GET /resource/sign_up # def new # super # end # POST /resource # def create # super # end # GET /resource/edit # def edit # super # end # PUT /resource # def update # super # end # DELETE /resource # def destroy # super # end # GET /resource/cancel # Forces the session data which is usually expired after sign # in to be expired now. This is useful if the user wants to # cancel oauth signing in/up in the middle of the process, # removing all OAuth session data. # def cancel # super # end protected def update_resource(resource, params) resource.update_without_password(params) end # If you have extra params to permit, append them to the sanitizer. # def configure_sign_up_params # devise_parameter_sanitizer.permit(:sign_up, keys: [:attribute]) # end # If you have extra params to permit, append them to the sanitizer. # def configure_account_update_params # devise_parameter_sanitizer.permit(:account_update, keys: [:attribute]) # end # The path used after sign up. # def after_sign_up_path_for(resource) # super(resource) # end # The path used after sign up for inactive accounts. # def after_inactive_sign_up_path_for(resource) # super(resource) # end end ```
退会済みユーザー

退会済みユーザー

2022/09/27 01:27

長文になってしまい、誠に申し訳ありません。
退会済みユーザー

退会済みユーザー

2022/09/27 02:28 編集

自己紹介文(self_introduction)がuserに用意されていないということらしいのですが、登録時には 自己紹介文はいらないので、除外する必要があると思ったのですが、この解釈で合っていますでしょうか?
退会済みユーザー

退会済みユーザー

2022/09/27 02:35

userのマイグレーションファイルとかってどんな感じになってますかね
退会済みユーザー

退会済みユーザー

2022/09/27 02:42

こちらです。 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 add_index :users, :email, unique: true add_index :users, :reset_password_token, unique: true # add_index :users, :confirmation_token, unique: true # add_index :users, :unlock_token, unique: true end end ```
guest

回答1

0

ベストアンサー

t.string :self_inroduction
t が落ちてますね。

投稿2022/09/27 06:11

winterboum

総合スコア23333

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

退会済みユーザー

退会済みユーザー

2022/09/27 06:29 編集

ありがとうございます。 マイグレーションファイルのカラム名の変更はdeviseではコマンド入力ではまたべつなのでしょうか? rails generate migration rename_self_inroduction_column_to_Users でもdeviseは大丈夫でしょうか?
winterboum

2022/09/27 06:35

その generationでどういうmigrationができるのかわかりませんが、正しいmigrationができるならOKです。 「deviseではコマンド入力ではまたべつなのでしょうか?」この質問の意味がわかりませんが。
退会済みユーザー

退会済みユーザー

2022/09/27 06:37

すみません。 rails generate migration rename_self_inroduction_column_to_Users のなかにdeviseを入れて、変更を行うとかをしないといけないのかと思ました。
退会済みユーザー

退会済みユーザー

2022/09/27 06:40

ありがとうございます! 無事、新規登録ができました。
winterboum

2022/09/27 06:40

migration は modelのdatabase table構成を管理する ということでしかないので、 deviseに必要なカラムを定義しているか 以外にdeviseを気にする必要はないです。
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問