Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/62.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html RubyonRails本地化_Html_Ruby On Rails - Fatal编程技术网

Html RubyonRails本地化

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>

我必须使用yml文件对网站进行本地化。但我在以下方面有问题:

<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行得到了一个错误。。