0

我试图实现这个代码,当我运行我的本地服务器时,我得到一个语法错误。我正在运行 rails 版本 3.2.11 并认为这可能与此代码有关。

<h1>Time Ajax Demo</h1>
<p><%= link_to 'Get Current Time', time_refresh_path, 
     remote: true %>
</p>
<p id='currentTime'>
Current time will appear here
</p>

这是我的错误:

syntax error, unexpected ':', expecting ')'
     remote: true );@output_buffer.safe_concat('
4

2 回答 2

0

我认为您正在使用 ruby1.8.X​​ 。如果您使用的 Ruby 版本少于1.9.X使用=>

<%= link_to 'Get Current Time', time_refresh_path, :remote => true %>
于 2013-03-14T19:33:17.290 回答
0

尝试link_to 'Get Current Time', time_refresh_path, :remote => true

http://api.rubyonrails.org/classes/ActionView/Helpers/UrlHelper.html#method-i-link_to

于 2013-03-14T19:03:43.947 回答