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

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

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

Deviseとは、Ruby-on-Railsの認証機能を追加するプラグインです。

Ruby

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

Ruby on Rails 6

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

Q&A

1回答

1491閲覧

rails devise導入するも、サインアップ画面にてArgumentError in Users::Registrations#newが出てしまう

hurousyotoku500

総合スコア27

Devise

Deviseとは、Ruby-on-Railsの認証機能を追加するプラグインです。

Ruby

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

Ruby on Rails 6

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

0グッド

0クリップ

投稿2020/11/05 21:12

rails初心者です。
状況としましては、手順通り、deviseを導入し、問題なくサインアップもログインもできていたのですが、いつからか画像のようなエラーが出るようになってしまいました。どこが悪いのか検討も付かなく困っております。
イメージ説明

ruby

1#registration_controller.rb 2# frozen_string_literal: true 3 4class Users::RegistrationsController < Devise::RegistrationsController 5 protected 6 7 def after_sign_up_path_for(resource) 8 # サインアップ後のリダイレクト先をrootに変更 9 root_path 10 end 11 12 def after_update_path_for(resource) 13 user_path(current_user) 14 end 15 16 def update_resource(resource, params) 17 resource.update_without_password(params) 18 end 19 20 # before_action :configure_sign_up_params, only: [:create] 21 # before_action :configure_account_update_params, only: [:update] 22 23 # GET /resource/sign_up 24 def new 25 26 end 27 28 # POST /resource 29 def create 30 super 31 end 32 33 # GET /resource/edit 34 # def edit 35 # super 36 # end 37 38 # PUT /resource 39 # def update 40 # super 41 # end 42 43 # DELETE /resource 44 # def destroy 45 # super 46 # end 47 48 # GET /resource/cancel 49 # Forces the session data which is usually expired after sign 50 # in to be expired now. This is useful if the user wants to 51 # cancel oauth signing in/up in the middle of the process, 52 # removing all OAuth session data. 53 # def cancel 54 # super 55 # end 56 57 # protected 58 59 # If you have extra params to permit, append them to the sanitizer. 60 # def configure_sign_up_params 61 # devise_parameter_sanitizer.permit(:sign_up, keys: [:attribute]) 62 # end 63 64 # If you have extra params to permit, append them to the sanitizer. 65 # def configure_account_update_params 66 # devise_parameter_sanitizer.permit(:account_update, keys: [:attribute]) 67 # end 68 69 # The path used after sign up. 70 # def after_sign_up_path_for(resource) 71 # super(resource) 72 # end 73 74 # The path used after sign up for inactive accounts. 75 # def after_inactive_sign_up_path_for(resource) 76 # super(resource) 77 # end 78end 79

ruby

1#new.html.erb 2<h2>Sign up</h2> 3 4<%= form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f| %> 5 <%= render "devise/shared/error_messages", resource: resource %> 6 7 <div class="field"> 8 <%= f.label :email %><br /> 9 <%= f.email_field :email, autofocus: true, autocomplete: "email" %> 10 </div> 11 12 <div class="field"> 13 <%= f.label :password %> 14 <% if @minimum_password_length %> 15 <em>(<%= @minimum_password_length %> characters minimum)</em> 16 <% end %><br /> 17 <%= f.password_field :password, autocomplete: "new-password" %> 18 </div> 19 20 <div class="field"> 21 <%= f.label :password_confirmation %><br /> 22 <%= f.password_field :password_confirmation, autocomplete: "new-password" %> 23 </div> 24 25 <div class="actions"> 26 <%= f.submit "Sign up" %> 27 </div> 28<% end %> 29 30<%= render "devise/shared/links" %> 31

ruby

1#user.rb 2class User < ApplicationRecord 3 # before_save { self.email.downcase! } 4 # validates :name, presence: true, length: { maximum: 50 } 5 # validates :email, presence: true, length: { maximum: 255 }, 6 # format: { with: /\A[\w+\-.]+@[a-z\d\-.]+.[a-z]+\z/i }, 7 # uniqueness: { case_sensitive: false } 8 # has_secure_password 9 10 has_many :messages 11 # has_many :scores 12 # Include default devise modules. Others available are: 13 # :confirmable, :lockable, :timeoutable, :trackable and :omniauthable 14 devise :database_authenticatable, :registerable, 15 :recoverable, :rememberable, :validatable 16 validates :name, presence: {message: 'を入力してください'} 17 18end 19

ruby

1#routes.rb 2devise_for :users, :controllers => { 3 :registrations => 'users/registrations', 4 :sessions => 'users/sessions' 5 } 6 devise_scope :user do 7 get "sign_in", :to => "users/sessions#new" 8 get "/users/sign_out", :to => "users/sessions#destroy" 9 end

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

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

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

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

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

guest

回答1

0

ruby

1 # GET /resource/sign_up 2 def new 3 super 4 end

投稿2020/11/05 22:42

asm

総合スコア15147

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

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

hurousyotoku500

2020/11/06 01:22

ご回答ありがとうございます。「super」追記してみましたが同じエラーがでます。
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

まだベストアンサーが選ばれていません

会員登録して回答してみよう

アカウントをお持ちの方は

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

ただいまの回答率
85.48%

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

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

質問する

関連した質問