Html RubyonRails本地化
我必须使用yml文件对网站进行本地化。但我在以下方面有问题:Html RubyonRails本地化,html,ruby-on-rails,Html,Ruby On Rails,我必须使用yml文件对网站进行本地化。但我在以下方面有问题: <tr> <td><%= link_to author.name, :action => 'show', :id => author %></td> <td><%= link_to 'Edit', :action => 'edit', :id => author %></td> <td>
<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>
'show',:id=>author%>
“编辑”,:id=>author%>
'destroy',:id=>author},
{:method=>:删除,
:confirm=>“是否确实要删除作者#{author.name}?”}%>
:confirm=>t(:sure_delete_author,:authorname=>{author.name})}%>
t(:delete)
正常工作,但确认按钮不起作用。保留原始文件和未使用的文件。问题在于,当没有字符串时,您试图使用字符串插值(这似乎是一个简单的复制和粘贴问题)
而不是
:authorname => #{author.name}
请尝试以下方法之一:
:authorname => "#{author.name}"
:authorname => author.name
最后一个当然是首选:)
PS:根据我个人的经验,使用新的Ruby 1.9散列语法可以消除大量的视觉混乱,并使发现此类问题变得更加容易。问题在于,在没有字符串的情况下,您试图使用字符串插值(这似乎是一个简单的复制和粘贴问题) 而不是
:authorname => #{author.name}
请尝试以下方法之一:
:authorname => "#{author.name}"
:authorname => author.name
最后一个当然是首选:)
PS:根据我个人的经验,使用新的Ruby 1.9哈希语法可以消除大量的视觉混乱,并使发现类似问题变得更加容易。你应该删除第7行,第8行不行。我只留下了7,这样你就可以看到8要做什么了,但是它在第10行得到了一个错误。你应该删除第7行,第7行有效,第8行无效。我刚刚离开了7,以便您可以看到8必须做什么,但是它在第10行得到了一个错误。。