![見出し画像](https://assets.st-note.com/production/uploads/images/37629102/rectangle_large_type_2_262aed8d7b96d1aea32949b233f038ae.png?width=1200)
Photo by
narukuni
【devise】ゲストログイン機能 編集できなくする
はじめに
ゲストログイン 機能の続きです。ゲストログイン機能の実装は前回のnoteを参照。
customers_controller.rb(※デバイスのコントローラではありません)
before_action :check_guest, only: %i[update withdraw]
def check_guest
if @customer.email == 'guestcustomer@example.com'
redirect_to root_path, notice: 'ゲストユーザーは編集できません。'
end
end
以上の記述だけで退会ができなくなります
この記事が気に入ったらサポートをしてみませんか?