call action, render it, then redirect back to itself

Why don't you call all of the unread books up into an array and then use javascript to walk through the array, either timed or upon a button click in the front end. You could even use AJAX to post the update_attributes to the server after the book has been read, rather than making tons of database calls, you could make 1.


I would achieve this by calling

def loop_type_action   book = Book.find_one_book_that_left #find a book haven't read   book.update_attribute("is_read",true) #mark it as read   @result = #fetch book content   headers["Refresh"] = "5; URL=" + url_for(:action => "loop_type_action") end

This will cause the page to refresh every 5 seconds, calling loop_type_action each time. You can change the number to the time you desire. You can also use expires_now() in the controller action and putting link_to(:action => "loop_type_action") in the view on an element like the book title or cover (in this example). Every time the user clicks, the page should refresh. expires_now causes it to not be cached.

I can also think of some Javascript things you could do to refresh the page only when certain conditions are true. You could also use Rails' support to provide graphical feedback while the action reloads. See < ScriptaculousHelper.html#M000515>.