How to use flash in ROR


#1

Hi,

How to use flash[:notice] in ruby to display error messages.
I have tried it into for loop as follows:-

for i in 0…(params[:product][:count].to_i-1)
if params[:product][‘demand’+(i).to_s].to_i >
params[:product][‘quantity’+(i).to_s].to_i
flash[:notice] ="#{params[:product][‘demand’+(i).to_s]} is less than
the
#{params[:product][‘quantity’+(i).to_s]}"
end
end
redirect_to :action => ‘index’, :id => @product

Here in above code when i get redirected to index action (on
index.rhtml) page I can see only erro rmesage asociated with last flash.
That is in above code i want to store message into flash for all
products for which above ‘if’ condition becomes true. So that i can
iterate throgh flash & see the error messages related with all products
for which ‘if’ condition true.

How to do this???

Thanx in advance.

Prash