Last Updated: February 25, 2016
·
925
· dvilla

How to authenticate only certain methods in your controller, using devise

Maybe a lot of people know how to do it but I struggled for a day trying to know how to do it, and if someone is wondering how, here is how

beforefilter :authenticateadmin!, :only => [:edit, :index, :update, :destroy, :show, :resolvecomplain]
beforefilter :authenticateuser!, :only => [:somemethod, :anothermethod]

In this case the user is only authenticated to to use somemethod and anothermethod and the admin can use edit, index, destroy, etc...