Rails, flash, function and parameter


I try do update the flash on my page with ajax.

I have this on my layout :

<%= render :partial => 'layouts/flash' %>

I have this on my ApplicationHelper :

def reload_flash
page.replace “flash_messages”, :partial => ‘layouts/flash’

and I try do that on my controller :

render :update do |page|
flash[:notice] = “Entering ‘beast mode’…”

but I have an error, to fix it i need to add a parameter page on my
function reload_flash and call this function with reload_flash(page)
instead of page.reload_flash, that’s work but I think It’s a bit
weird, I prefer write something without parameter.
Do you know how i can do that ?

In fact this code is from this page
and the author says he use it. Is it with available in an older
version of rails ?

Hi Adrien,

methods you define in your helpers are not available on the page

Thus, as you described, if you want to call your helper-method
‘reload_flash’ in the controller, you have to pass the page param…

I doubt that the code of the example you describe ever worked with any


Ok thanks !
It’s a bit strange because the author of the webpage seems happy to
discover that but i understand why it’s not possible.