Tuesday, 24 January 2012

Return user to paginated list page after delete or edit event

The easy way to send your users back the same list page (page number, ordering) they were on prior to selecting an item for edit (or deleting it non-ajax style with full postback) is to store the referring path in session and redirect to it when the task is done, like so:
def destroy #or whatever you're handling
  session[:return_to] = request.referer
  #do whatever you need to do here
  redirect_to session[:return_to]

No comments:

Post a Comment

Comments are moderated, so you'll have to wait a little bit before they appear!