In my application controller, I have a function like this:
if cur_user.role != “Admin” && cur_user.id != Integer(user_id)
flash[:error] = “Access denied”
redirect_to(:controller => :users, :action => :account) and return
I call it in my users controller like so:
@user = User.find_by_id(params[:id])
flash[:error] = “User not found”
redirect_to :action => :account
If @user ends up being nil, however, then I get a DoubleRender error.
My question is, what can I put in “is_owner_or_admin” that will redirect
and not complete the “show” action?