# Rails, flash, function and parameter

**URL:** <https://www.ruby-forum.com/t/rails-flash-function-and-parameter/176886>\
**Category:** Rails\
**Created:** [October 7, 2009, 4:51pm UTC](https://www.ruby-forum.com/t/rails-flash-function-and-parameter/176886 "2009-10-07T16:51:29Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![korn900](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/5daacb/32.png) [@korn900](https://www.ruby-forum.com/u/korn900)\
**Post date:** [October 7, 2009, 4:51pm UTC](https://www.ruby-forum.com/t/rails-flash-function-and-parameter/176886/1 "2009-10-07T16:51:29Z")

</div>

Hi,

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’  
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/](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 ?

---

<div class="post-metadata">

**Author:** ![korn900](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/5daacb/32.png) [@korn900](https://www.ruby-forum.com/u/korn900)\
**Post date:** [October 8, 2009, 10:55am UTC](https://www.ruby-forum.com/t/rails-flash-function-and-parameter/176886/2 "2009-10-08T10:55:42Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![korn900](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/5daacb/32.png) [@korn900](https://www.ruby-forum.com/u/korn900)\
**Post date:** [October 8, 2009, 8:49pm UTC](https://www.ruby-forum.com/t/rails-flash-function-and-parameter/176886/3 "2009-10-08T20:49:22Z")

</div>

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
