I read the rails book about build Store" Add a date and time to the sidebar. It doesn’t have to update: just show the value at the time the page was displayed". There is an answer from the page which the book provided.
One of these from Ken is :
using ajax to test this out so, in my index page I added:
<div id="time">
<%= @current_time %>
</div>
<div id="ajax_update">
<%= periodically_call_remote(:url =>{ :controller => "store", :action => "current_time"}, :frequency => 1) %>
</div>
and created an rjs for the controller with this:
def current_time
page.replace_html "time", Time.now.strftime("%m-%d-%Y %H:%M:%S")
end
But question is how to creat a rjs and connect to controller, and how to write the codes to make it work? I am new railser. thanks a lot