Probably easy q: flash before redirect

I’m a little perplexed why this isn’t working:

private
def check_authorization
user = User.find(session[:user])
if user.level == 100
flash[:notice] = “welcome, admin”
else
flash[:notice] = “ha ha”
redirect_to :controller =>“account”, :action
=>“signup”
flash[:notice] = “You are not an admin!!”
end
end
end

The first part (when user.level == 100) is ok but in the 2nd part it
goes directly to account/signup without displaying either flash message.
I’ve tried putting it before the redirect, after the redirect, both,
etc. nothing.

What’d I miss?

Vince W. wrote:

I’m a little perplexed why this isn’t working:

private
def check_authorization
user = User.find(session[:user])
if user.level == 100
flash[:notice] = “welcome, admin”
else
flash[:notice] = “ha ha”
redirect_to :controller =>“account”, :action
=>“signup”
flash[:notice] = “You are not an admin!!”
end
end
end

The first part (when user.level == 100) is ok but in the 2nd part it
goes directly to account/signup without displaying either flash message.
I’ve tried putting it before the redirect, after the redirect, both,
etc. nothing.

What’d I miss?

Maybe a stupid question, but do you actually print out flash[:notice]
anywhere on the signup page? I assume the check_authorization view has
the print statement in it.

Maybe a stupid question, but do you actually print out flash[:notice]
anywhere on the signup page? I assume the check_authorization view has
the print statement in it.

Actually not a stupid question at all… that’s exactly what it was.
Learn something new every day…

Thanks very much!

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs