flash notice is lost on redirect, how to find out what's removing it?

There are many posts on SO about this ( respond_with redirect with notice flash message not working Why is :notice not showing after redirect in Rails 3, among others) , I've read at least 4 and still can't solve this issue.

I've got a portion of my site that lets people do some things before they create an account. I prefer this from a UX perspective. So they're allowed to do X and Y then they get redirected to the "Create account" page (uses Devise).

The redirect looks like:

if userIsNew 
  ... stow information in a cookie to be retrieved later ...     
  redirect_to "/flash", flash[:notice]  
    => "Ok, we'll get right on that after you sign up (we need your email)." 
      and return # this has to be here, since I'm terminating the action early
end 

So "/flash" is a plain page that I made to test this. It doesn't do anything, has no markup of its own, just has the basic html from the application.html, which has this line in the body:

 <% if flash[:notice] %>
    <p><%= notice %></p>
 <% else %>
  No notice!
 <% end %>

It says 'No notice' every time.

I have tried:

  • adding in a flash.keep to my before_filter in the static controller
  • using :notice => instead of flash[:notice] =>
  • putting the notice in a cookie and pulling that text out of the cookie and into a flash in the before_filter of my application controller
  • redirect_to :back with the flash[:notice] =>

Answers


It's either

flash[:notice] = 'blablabla'
redirect_to foo_url

or

redirect_to foo_url, notice: 'blablabla'


Need Your Help

Rails how to create an initializer inside a gem

ruby-on-rails-3 gem initializer

I am trying to build a gem in Rails 3 and inside it i am trying to pass an initializer:

Java Challenge on A Gradient Color Canvas

java graphics gradient shapes

This is probably an elementary question. However, I have completed reading the 9th Chapter of Java Programming for the Absolute Beginner and have approached the Challenges section. I cannot quite...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.