[error:flash function] message will not be displayed on some condition.

Hello fellows. I have a issue on Ruby regarding error notice function (Flash). The error message will not be displayed on some condition.

This issue occurs on the system which I wrote below. (There is no problem when I am using local PC enviornment "WEBrick") Specifically, the issue is, There is no problem displaying the value from flash when the controler is set for error notice view. However, when I set the value on other controler such as "application.rb" the value will not show up.

Below is my system enviornment and the source code that I wrote for ROR and rhtml.

System enviornment Red Hat Enterprise Linux 4.0 ES Apache 2.0.52 MySQL 4.1.20 modssl 2.0.52 / fastcgi Ruby 1.8.4 Rails 1.1.6 The source code I wrote follows

Ruby on Rails source code; flash[:notice] = 'error message'

rhtml source code; <% if @flash[:notice] %> <%= @flash[:notice] %> <% end %>

Please help me!! Best Regards, marai

You shouldn’t use the @flash variable directly. This is depricated. Aslo, once the flash is accessed i believe it’s cleared.

You could use something like

<% if fl = flash[:notice] %>

<%= fl %>

<% end %>

Alternatively there are a number of solutions to displaying the flash messages. One off hand is,

http://rails.techno-weenie.net/tip/2006/7/13/another-flash-display-helper

Hope that helps

Daniel N, Thank you for your help and advice. I'll try it.

You shouldn't use the @flash variable directly. This is depricated. Aslo, once the flash is accessed i believe it's cleared.

You could use something like

<% if fl = flash[:notice] %> <%= fl %> <% end %>

Alternatively there are a number of solutions to displaying the flash messages. One off hand is, http://rails.techno-weenie.net/tip/2006/7/13/another-flash-display-he

Best Regards marai