Rails, flash, function and parameter

Hi,

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

I have this on my layout :

<div id="flash_messages"> <%= render :partial => 'layouts/flash' %> </div>

I have this on my ApplicationHelper :

def reload_flash   page.replace "flash_messages", :partial => 'layouts/flash' end

and I try do that on my controller :

render :update do |page|   flash[:notice] = "Entering 'beast mode'..."   page.reload_flash end

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 http://www.whatcodecraves.com/articles/2008/12/13/rails_flash_with_ajax/ 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 object.

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 rails-version...

Andi

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.

Adrien