2013-05-14 134 views
1

我必须使用yml文件本地化一个网站。但我有问题,以下内容:Ruby on Rails本地化

<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)的作品,因为它应该,但确认没有。留下原来的和不工作的。

+1

你应该删除线#7 – NARKOZ 2013-05-14 07:49:23

+1

7号线的作品,8不。我刚刚离开了7,这样你就可以看到8要做什么了,但是它会在第10行得到一个错误。 – MustSeeMelons 2013-05-14 07:56:41

回答

1

的问题是,你要使用字符串插值时,有没有字符串(这似乎是一个简单的复制和粘贴问题)

而不是

:authorname => #{author.name} 

尝试之一这些:

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

课程的最后一个将是优选的:)

PS:在我个人的经验中,使用新的Ruby 1.9哈希语法消除了大量的视觉混乱,并使得发现这样的问题变得更容易。

+0

感谢队友,像一个魅力:) – MustSeeMelons 2013-05-14 08:07:18