Using translation variable in link_to

HI ,

In ROR , i m having a line like

     <%= link_to("NAME (#{@name})", user_path(@user, :in => :s)) %>

i want to change the string NAME to t(:str_name) ..

how to change it . when i change it , i am getting errors..

···

--
Posted via http://www.ruby-forum.com/.

you should ask on the rubyonrails forum instead.

···

On Sep 15, 2010, at 23:39 , Aruna Chinnamuthu wrote:

HI ,

In ROR , i m having a line like

    <%= link_to("NAME (#{@name})", user_path(@user, :in => :s)) %>

i want to change the string NAME to t(:str_name) ..

how to change it . when i change it , i am getting errors..

Without the actual error message I'm guessing but you probably want something like:

<%= link_to("#{t(:str_name)} (#{@name})", user_path(@user, :in => :s)) %>

And if that fixes your problem then, ruby-talk was an appropriate place for the
question since it is just a language issue and not a Rails issue.

Gary Wright

···

On Sep 16, 2010, at 2:39 AM, Aruna Chinnamuthu wrote:

In ROR , i m having a line like

    <%= link_to("NAME (#{@name})", user_path(@user, :in => :s)) %>

i want to change the string NAME to t(:str_name) ..

how to change it . when i change it , i am getting errors..

Gary Wright wrote:

···

On Sep 16, 2010, at 2:39 AM, Aruna Chinnamuthu wrote:

In ROR , i m having a line like

    <%= link_to("NAME (#{@name})", user_path(@user, :in => :s)) %>

i want to change the string NAME to t(:str_name) ..

how to change it . when i change it , i am getting errors..

Without the actual error message I'm guessing but you probably want
something like:

<%= link_to("#{t(:str_name)} (#{@name})", user_path(@user, :in => :s))
%>

And if that fixes your problem then, ruby-talk was an appropriate place
for the
question since it is just a language issue and not a Rails issue.

Gary Wright

Thanks Gary .
Its worked for me..

--
Posted via http://www.ruby-forum.com/\.