0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

privateメソッドの記述。

Posted at

このようなエラーが出ました。確認したところ、sessions_controllerのdestroyの記述は問題ありません。

スクリーンショット 2021-07-18 12.45.53.png

sessions_controller.rb
  private
  
  def login_form_params
    params.require(:admin_login_form).permit(:email,:password)
  end

  def destroy
    session.delete(:administrator_id)
    flash.notice = "ログアウトしました。"
    redirect_to :admin_root
  end
end

上記のように記述すると、private以下すべての処理に適応されてしまいます。

sessions_controller.rb
  private  def login_form_params           <==ここを変更。
    params.require(:admin_login_form).permit(:email,:password)
  end

  def destroy
    session.delete(:administrator_id)
    flash.notice = "ログアウトしました。"
    redirect_to :admin_root
  end
end

これで指定した処理にのみprivateが適応されます。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?