flash[] and Rails 2.0

Prior to rails 2.0, @flash contained the same thing as flash (but was deprecated). When you do render :partial => 'flash', it picks up on the @flash variable (which is still there but nil) and assigns that to flash in your partial. So you can get round this by: -renaming your partial -using flash()[:foo] instead of flash[:foo] (which will tell ruby to do the method call rather than use the local variable


I just ran into this problem too. Thanks for the advice Frederick, as that was the issue. I named my partial "flash", and I forget that partials automatically get a local variable with the same name.

For example, if you create a partial named "product", and then use <%= render :partial => "product", :collection => @products %>

The partial will have a local variable "product" that represents the product for each one. Rails will happily override the flash hash with the partial name (and set it to nil).