# Need help with calling a ruby method inside rhtml

**URL:** <https://www.ruby-forum.com/t/need-help-with-calling-a-ruby-method-inside-rhtml/108087>\
**Category:** Rails\
**Created:** [June 28, 2007, 11:21pm UTC](https://www.ruby-forum.com/t/need-help-with-calling-a-ruby-method-inside-rhtml/108087 "2007-06-28T23:21:54Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Manic](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/7bcc69/32.png) [@Manic](https://www.ruby-forum.com/u/Manic)\
**Post date:** [June 28, 2007, 11:21pm UTC](https://www.ruby-forum.com/t/need-help-with-calling-a-ruby-method-inside-rhtml/108087/1 "2007-06-28T23:21:54Z")

</div>

My problem is simple. I have a function “translateTo(lang)” that i  
need to call in my show\_data.rhtml file. The function that i need to  
call returns a string that i need to print out on my show\_data.rhtml  
page.

Should i define the function in the show\_data\_controller.rb? or some  
were else?

What commands should i have in the show\_data.rhtml?

show\_data.rhtml file  
…  
…  
…  
\<%= translateTo(@trans)%\> \<%# What shall i do to make this line work  
%\>  
…  
…

---

<div class="post-metadata">

**Author:** ![Manic](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/7bcc69/32.png) [@Manic](https://www.ruby-forum.com/u/Manic)\
**Post date:** [June 28, 2007, 11:31pm UTC](https://www.ruby-forum.com/t/need-help-with-calling-a-ruby-method-inside-rhtml/108087/2 "2007-06-28T23:31:55Z")

</div>

Hi, you should define the in the application\_helper.rb if it is to be  
used by all views or show\_data\_helper if it is only to be used with  
views of show\_data.

Good luck,

-Conrad

---

<div class="post-metadata">

**Author:** ![Manic](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/7bcc69/32.png) [@Manic](https://www.ruby-forum.com/u/Manic)\
**Post date:** [June 28, 2007, 11:32pm UTC](https://www.ruby-forum.com/t/need-help-with-calling-a-ruby-method-inside-rhtml/108087/3 "2007-06-28T23:32:55Z")

</div>

Hi, you should define the in the application\_helper.rb if it is to be  
used by all views or show\_data\_helper if it is only to be used with  
views of show\_data.

Good luck,

-Conrad
