Javascript rails4-Ajax。定时器实现

Javascript rails4-Ajax。定时器实现,javascript,ruby-on-rails,ajax,ruby-on-rails-4,Javascript,Ruby On Rails,Ajax,Ruby On Rails 4,我有一个示例应用程序,它运行良好,但需要较旧的Rails版本。 以下是控制器代码: class AjaxController < ApplicationController def show end def time render text: "The current time is #{Time.now.to_s}" end end 下面是查看代码: <%= javascript_include_tag :defaults %> <h1>

我有一个示例应用程序,它运行良好,但需要较旧的Rails版本。 以下是控制器代码:

class AjaxController < ApplicationController
  def show
  end

  def time
    render text: "The current time is #{Time.now.to_s}"
  end
end
下面是查看代码:

<%= javascript_include_tag :defaults %>
<h1>Ajax show</h1>
Click this link to show the current 
<%= link_to_remote "time", 
    :update => 'time_div', 
    :url => {:action => "time"} %>.<br/>
<div id='time_div'>
</div>

Rails 4.0.2没有“link\u to\u remote”,但在“link\u to”中有:remote属性。但是,即使使用此替换,此代码也不起作用。我该怎么办?谢谢。

请发布更新后的视图代码,其中的链接不起作用。可能存在重复的