7

I am a newbie in Ruby On Rails, Can someone tell me how to refresh a page.

  1. Without any values submitted
  2. With previous values submitted
2
  • 1
    When you say "refresh" do you mean the page will automatically refresh itself every "n" minutes, or is there a control (e.g., button) that the user will activate to refresh the page? Commented Jan 19, 2010 at 19:58
  • it will automatically refresh Commented Jan 19, 2010 at 19:59

2 Answers 2

7

ActionView::Helpers::PrototypeHelper#periodically_call_remote:

  1. Without any values submitted

    <%= periodically_call_remote(:url => {}) %>
    
  2. With previous values resubmitted:

    <%= periodically_call_remote(:url => params) %>
    

You can provide a :frequency option to specify how often to call it.

You may also want to set up the format.js block in the controller to render an RJS template that will only update things that could change.

Edit: This approach was deprecated with version Rails 3.0

This question (Rails 3 equivalent for periodically_call_remote) provides a method for accomplishing this in newer versions of Ruby on Rails.

Sign up to request clarification or add additional context in comments.

2 Comments

Your link seems to be broken.
Not broken, just deprecated. I've updated the link to point to the documentation of the last version of rails this was supported, I've also added a link to answer that provides an method of accomplishing this in newer versions of Rails.
1

You could also use the below script to auto refresh a full page...

setTimeout("location.reload();",10000);

1 Comment

script language="javascript" type="text/javascript

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.