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
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2020/11/06 01:22