I have a User model generated by Devise. So, I have before filter authenticate_user.
I have used STI and created 2 more models UserA < User, UserB < User.
User has a field 'type' which determines whether user object is of type 'UserA' or 'UserB'.
I have some controllers in which I want specific filter, like, can be seen only by user type 'UserA' or UserB. So, I want to write a filter like this:
def authenticate_usera
if current_user.type == 'usera'
return true
else
return false
end
def authenticate_userb
if current_user.type == 'userb'
return true
else
return false
end
Question:
So, where should I place this filter code? And, can I use like this in controller:
before_filter :authenticate_usera
Also, do I need to use anything like 'require' for that filter to be available in this ?