Rails 4 - Ajax。定时器实现

时间:2015-07-10 15:28:14

标签: 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>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_to_remote',但在'link_to'中有:remote属性。但是,即使使用此替换,此代码也不起作用。我该怎么办?谢谢。

0 个答案:

没有答案