The Accelerate HR Blog

My Back Pages   (Mon Nov 12 2007)

ACCELERATE HR is a database with complex links, and there are often several access points for a single page. How then to return to the correct access page when you've finished working on the destination page?

Let's take a simple example. We're working on overtime entry for a single department. There are two possible access points for the new overtime entry page. One is a listing of the business's departments showing existing overtime records over the last 12 months. The second is a similar department listing, but this time the records are for a single month. Making it a bit more complicated, the month can be set by the user. When we return to this page, we want the same month's data to be displayed.

OK, you say. Follow the link to the overtime entry page and then use the browser's Back button. But it's not that simple. What if the user has processed new overtime data and has been taken to a 'Show' page? That's where the browser button is going to take you, not back to the original department listing - or not directly anyway.

This is the simple method I find I'm using lots.

Step 1. In the controller def for each of the possible access pages, add the line:

session[:return_to] = request.request_uri

Step 2. In the controller referencing the destination page, add:

def goback
redirect_to session[:return_to]
end

Step 3. Add a link to goback in the view for the destination page. Something like:

<%= link_to 'Select another department', :action => 'goback' %>

And that's it. You're back to the page where you started. If your access page was the month's overtime listing for October this year, it's October you'll go back to. If November, then November. Or the records for the last 12 months. And this isn't just for page redirects from the view. You can redirect_to session[:return_to] in your controller updates and creates too.

But there's one more reason why this approach wins hands down over the browser Back button. Suppose you've changed the data from the destination page - in my example, we've added new overtime. And suppose there's a reference to the model data on the access page - a summary of the overtime totals calculated in the model, say. Using the method I've described here, the totals will be recalculated as you return to the access page. Not so with the browser Back button. You'll see the original cached data.

And I suppose that brings us on to caching. But that's for another time.

Filed under: Ruby on Rails






List recent Entries
List all blog entries filed under:

Employment Politics
HR
Implementation
Just thoughts
Ruby on Rails
Web 2.0

Can't find what you're looking for? Try this: -

Search blog for a word or phrase



 Subscribe to an RSS feed

Or get an email copy every time we post something new. Nothing new? Nothing mailed

Enter your email address:

Delivered by FeedBurner


If you're enjoying our blog, why not find out more, and maybe get involved?

ACCELERATE HR is a website built on Rails and designed for the enterprise. And we're building it live on the Web, right here.

Check out our home page HERE, or sign up for free HERE.


DESERT ISLAND BLOGS

Sharing a few of my favorites

HR Stimuli
McArthur's Rant

Jon Ingham's Strategic Human Capital Management Blog

The Rails Track
Railscasts

Web Power
The Technology Edge

Window on the Gulf
Mahmood's Den