# Flash\[:symbol\] with html possible?

**URL:** <https://www.ruby-forum.com/t/flash-symbol-with-html-possible/120607>\
**Category:** Rails\
**Created:** [November 19, 2007, 5:33am UTC](https://www.ruby-forum.com/t/flash-symbol-with-html-possible/120607 "2007-11-19T05:33:56Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![yachtman](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/d07c76/32.png) [@yachtman](https://www.ruby-forum.com/u/yachtman)\
**Post date:** [November 19, 2007, 5:33am UTC](https://www.ruby-forum.com/t/flash-symbol-with-html-possible/120607/1 "2007-11-19T05:33:56Z")

</div>

Trying to put in my controller

```
Flash[:notice] = "<%= #{link_to 'edit', :action => 'edit'} =>"

```

but, I get a “undefined method link\_to” error.

I would think that the :notice code would be rendered in the view,  
which should work and not get the “undefined method” error, but this  
does not seem the case. It appears that its rendered in the controller  
where I guess this method is undefined. Is there a way to force the  
rendering to occur in the view? Or am I totally missing something  
here?

---

<div class="post-metadata">

**Author:** ![yachtman](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/d07c76/32.png) [@yachtman](https://www.ruby-forum.com/u/yachtman)\
**Post date:** [November 19, 2007, 8:48am UTC](https://www.ruby-forum.com/t/flash-symbol-with-html-possible/120607/2 "2007-11-19T08:48:43Z")

</div>

On 19 Nov 2007, at 04:33, yachtman wrote:

> does not seem the case. It appears that its rendered in the controller  
> where I guess this method is undefined. Is there a way to force the  
> rendering to occur in the view? Or am I totally missing something  
> here?

flash[:notice] is not something magic, it’s just a hash which persists  
(in the session) across requests, and obviously that srting is just a  
regular old string, so interpolation happens exactly as it would  
normally. There’s no rendering going on here.

There are various howtos on the web about using view helpers from your  
controllers, which would be one way of solving your problem.

Fred

---

<div class="post-metadata">

**Author:** ![yachtman](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/d07c76/32.png) [@yachtman](https://www.ruby-forum.com/u/yachtman)\
**Post date:** [November 19, 2007, 8:57am UTC](https://www.ruby-forum.com/t/flash-symbol-with-html-possible/120607/3 "2007-11-19T08:57:29Z")

</div>

Fred,

> flash[:notice] is not something magic, it’s just a hash which persists  
> (in the session) across requests, and obviously that srting is just a  
> regular old string, so interpolation happens exactly as it would  
> normally. There’s no rendering going on here.

Understood. But I guess I am confused as to why this would not work,  
since if I place this exact same code:

```
"ink_to 'edit', :action => 'edit'}"

```

in the resulting view, it has no problem finding this method and  
displaying it. So it seems that the utilization of this method  
“link\_to” is happening before it even gets to the view???

> There are various howtos on the web about using view helpers from your  
> controllers, which would be one way of solving your problem.

I must admit that I have not utilized these yet, so I’ll do some more  
homework.

Thanks!

On Nov 19, 3:47 pm, Frederick C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![yachtman](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/d07c76/32.png) [@yachtman](https://www.ruby-forum.com/u/yachtman)\
**Post date:** [November 19, 2007, 9:10am UTC](https://www.ruby-forum.com/t/flash-symbol-with-html-possible/120607/4 "2007-11-19T09:10:20Z")

</div>

On 19 Nov 2007, at 07:56, yachtman wrote:

> since if I place this exact same code:
> 
> “ink\_to ‘edit’, :action =\> ‘edit’}”
> 
> in the resulting view, it has no problem finding this method and  
> displaying it. So it seems that the utilization of this method  
> “link\_to” is happening before it even gets to the view???  
> Yes. It’s just an ordinary string you’ve got there so the  
> interpolation happens when it is declared  
> Or to put things another way. if you had

a = " #{Time.now} "

then Time.now gets evaluated straight away. the fact that you’ve  
written flash[:notice] instead of a and stuff involving link\_to  
instead of Time.now changes nothing.  
I’m guessing you thought the use of \<%= in your string would make  
something special happen, but that’s not the case.

Fred
