What is the correct way to use the guard clause in this sample?
def require_admin
unless current_user && current_user.role == 'admin'
flash[:error] = "You are not an admin"
redirect_to root_path
end
end
I don't know where to put flash message when trying to rewrite using these https://github.com/bbatsov/ruby-style-guide#no-nested-conditionals conventions
return if current_user&.role == 'admin'
which is even more succinct. – Regardful