# Probably easy q: flash before redirect

**URL:** <https://www.ruby-forum.com/t/probably-easy-q-flash-before-redirect/93999>\
**Category:** Rails\
**Created:** [April 17, 2006, 9:47pm UTC](https://www.ruby-forum.com/t/probably-easy-q-flash-before-redirect/93999 "2006-04-17T21:47:47Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![vince](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/b5e925/32.png) [@vince](https://www.ruby-forum.com/u/vince)\
**Post date:** [April 17, 2006, 9:47pm UTC](https://www.ruby-forum.com/t/probably-easy-q-flash-before-redirect/93999/1 "2006-04-17T21:47:47Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![vince](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/b5e925/32.png) [@vince](https://www.ruby-forum.com/u/vince)\
**Post date:** [April 17, 2006, 10:03pm UTC](https://www.ruby-forum.com/t/probably-easy-q-flash-before-redirect/93999/2 "2006-04-17T22:03:02Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![vince](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/b5e925/32.png) [@vince](https://www.ruby-forum.com/u/vince)\
**Post date:** [April 17, 2006, 10:11pm UTC](https://www.ruby-forum.com/t/probably-easy-q-flash-before-redirect/93999/3 "2006-04-17T22:11:14Z")

</div>

> 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!
