help my in that question:
i have 2 models ( admin and user ) -> created with devise, and i have post_controller:
and the question arises:
if i have one m
Try using two before filters - one for admin only actions, and another for admin or user actions.
# ensure admin for other actions
before_filter :check_admin_logged_in!, :except => [:show, :index]
# ensure user or admin logged in for these actions (:only option is optional)
before_filter :check_user_logged_in!, :only => [:show, :index]
private
def check_admin_logged_in! # admin must be logged in
authenticate_admin!
end
def check_user_logged_in! # if admin is not logged in, user must be logged in
if !admin_signed_in?
authenticate_user!
end
end