app/controllers/topics_controller.rb
# If someone is trying to access admin's topic edit and himself is
# not an admin (!current_user.admin?), he should be redirected.
If someone is trying to access admin's topic edit and himself is
not an admin (!current_user.admin?), he should be redirected.
If someone is trying to access admin ' s topic edit and himself is not an admin ( !current_user . admin? ) he should be redirected .
def redirect_if_not_an_admin
    return unless @topic.user.admin? && !current_user.admin?
    flash[:danger] = 'Access denied.'
    redirect_to root_path
  end
def redirect_if_not_an_admin return unless @topic . user . admin? && ! current_user . admin? flash [ :danger ] = 'Access denied.' redirect_to root_path end
If someone is trying to access admin's topic edit and himself is
not an admin (!current_user.admin?
If someone is trying to access admin ' s topic edit and himself is not an admin ( !current_user . admin?