MustSeeMelons
MustSeeMelons

Reputation: 756

Ruby on Rails localization

I have to localize a web site with using the yml files. But I'm having problems with the following:

<tr>
    <td><%= link_to author.name, :action => 'show', :id => author %></td>
    <td><%= link_to 'Edit', :action => 'edit', :id => author %></td>
    <td>
        <%= button_to t(:delete), {:action => 'destroy', :id => author},
        {:method => :delete,
        :confirm => "Are you sure you want to delete author #{author.name}?"} %>
        :confirm => t(:sure_delete_author, :authorname=>#{author.name}) } %>
    </td>
</tr>

t(:delete) works as it should, but the confirm doesn't. Left the original and the not working one.

Upvotes: 1

Views: 101

Answers (1)

Daniel Rikowski
Daniel Rikowski

Reputation: 72544

The problem is that you are trying to use string interpolation when there is no string (which seems to be a simple copy-and-paste problem)

Instead of

:authorname => #{author.name}

try one of these:

:authorname => "#{author.name}"
:authorname => author.name

The last one of course is to be preferred :)

PS: In my personal experience using the new Ruby 1.9 hash syntax removes a lot of visual clutter and makes spotting problems like this a lot easier.

Upvotes: 1

Related Questions