# H() aka. html\_escape in controller code?

**URL:** <https://www.ruby-forum.com/t/h-aka-html-escape-in-controller-code/52421>\
**Category:** Rails\
**Created:** [January 13, 2006, 10:42pm UTC](https://www.ruby-forum.com/t/h-aka-html-escape-in-controller-code/52421 "2006-01-13T22:42:52Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Zack\_C](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/eb9ed0/32.png) [@Zack\_C](https://www.ruby-forum.com/u/Zack_C)\
**Post date:** [January 13, 2006, 10:42pm UTC](https://www.ruby-forum.com/t/h-aka-html-escape-in-controller-code/52421/1 "2006-01-13T22:42:52Z")

</div>

Hi.

In controller code I’m doing things like:

flash[:success] = “Customer {#@customer.name} has been deleted.”

I know how to escape html in views by using the h() method. How can I  
do  
the same thing here in the controller?

Thanks,  
Zack

---

<div class="post-metadata">

**Author:** ![Zack\_C](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/eb9ed0/32.png) [@Zack\_C](https://www.ruby-forum.com/u/Zack_C)\
**Post date:** [January 14, 2006, 4:42am UTC](https://www.ruby-forum.com/t/h-aka-html-escape-in-controller-code/52421/2 "2006-01-14T04:42:00Z")

</div>

I don’t think you would do it there – instead, add  
“h(flash[:success])” to your view. (Keep the presentation separate.)
