ログインの画面を作りたいのですが、ログインボタンを押すと以下のエラーメッセージが出て、ここからわかりません。
初心者で申し訳ございませんがぜひ、ご教授お願い致します。
コードは以下の通りです。
controller
class UsersController < ApplicationController skip_before_action :verify_authenticity_token before_action :authorize, except: [:sign_up, :sign_up_process, :sign_in, :sign_in_process] before_action :redirect_to_top_if_signed_in, only: [:sign_up, :sign_in] # ユーザー登録ページ def sign_up @user = User.new render layout: "application_not_login" end # サインインページ def sign_in @user = User.new render layout: "application_not_login" end def sign_out #ここに処理を実装 user_sign_out #サインインページへ遷移 redirect_to sign_in_path and return end # サインイン処理 def sign_in_process # パスワードをmd5に変換 password_md5 = User.generate_password(user_params[:password]) # メールアドレスとパスワードをもとにデータベースからデータを取得 user = User.find_by(email: user_params[:email], password: password_md5) if user # セッション処理 user_sign_in(user) # トップ画面へ遷移する redirect_to top_path and return end end #ユーザー登録処理 def sign_up_process user = User.new(user_params) if user.save #登録が成功したらサインインしてトップページへ user_sign_in(user) redirect_to ('/top') else #登録が失敗したらユーザー登録ページへ flash[:danger] = "ユーザー登録に失敗しました。" redirect_to('/') end end private def user_params params.require(:user).permit(:name, :email, :password) end #現在サインイン中のユーザー情報を返す def current_user if @current_user.nil? @current_user = User.find_by(id: session[:user_id]) else @current_user end end end
html
<div class="sign_in"> <div class="contents"> <div class="sign_in_form"> <h1>Photo</h1> <form method="post" action="#"> <div class="field"> <input type="email" name="user_email" placeholder="メールアドレス"> </div> <div class="field"> <input type="password" name="password" placeholder="パスワード"> </div> <button>サインインする</button> </form> </div> <div class="sign_in_link"> <p>アカウントをお持ちですか? <a href="/sign_up">新規登録する</a></p> </div> </div> </div>
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。