app/controllers/application_controller.rb
def check_permission(role)
    unless @current_user.has_role?(role)
      @role = role.to_s.titleize
      # return render :template => "exceptions/permission_denied", :status => :unauthorized
      flash[:error] = "You are not authorized to view this page. You must be assigned the #{@role} role."
      redirect_to root_path
    end
  end
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
Prevent CSRF attacks by raising an exception.
For APIs, you may want to use :null_session instead.
Prevent CSRF attacks by raising an exception . For APIs you may want to use : null_session instead .
def check_permission(role)
    unless @current_user.has_role?(role)
      @role = role.to_s.titleize
      flash[:error] = "You are not authorized to view this page. You must be assigned the #{@role} role."
      redirect_to root_path
    end
  end
def check_permission ( role ) unless @current_user . has_role? ( role ) @role = role . to_s . titleize flash [ :error ] = "You are not authorized to view this page. You must be assigned the #{@role} role." redirect_to root_path end end
Prevent CSRF attacks by raising an exception.
Prevent CSRF attacks by raising an exception .
# return render :template => "exceptions/permission_denied", :status => :unauthorized
role