app/controllers/users_controller.rb
# Should be used when logged in user don't have rights to perform given action
Should be used when logged in user don't have rights to perform given action
Should be used when logged in user don ' t have rights to perform given action
def redirect_if_insufficient_permissions
    return if current_user == @user ||
              current_user.admin? ||
              current_user.moderator?
    flash[:danger] = 'Access denied.'
    redirect_to root_path
  end
def redirect_if_insufficient_permissions return if current_user == @user || current_user . admin? || current_user . moderator? flash [ :danger ] = 'Access denied.' redirect_to root_path end
Should be used when logged in user don't have rights to perform given action
Should be used when logged in user don ' t have rights to perform given action