Devise before_filter authenticate_admin?

前端 未结 2 1281
天命终不由人
天命终不由人 2021-02-05 18:02

I added an admin role to Devise by adding a admin attribute.

Could you tell me if this is the right way to create a before_filter that requires an admin user to be signe

2条回答
  •  梦毁少年i
    2021-02-05 18:20

    Looking at the answer above (by Michael De Silva), I had an issue with the code he used. He wrote the path as a symbol (:new_user_session_path), but I needed it to be a regular path helper (new_user_session_path). Until I changed this, I was getting errors, saying the path was invalid. (I am running Rails 5.)

    Hope this is helpful to others!

提交回复
热议问题