Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

A Rails plugin that provides a mechanism for storing URLs to return to at a later time.

tree: 048cc8020b

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 lib
Octocat-spinner-32 rails
Octocat-spinner-32 spec
Octocat-spinner-32 .gitignore
Octocat-spinner-32 CHANGELOG
Octocat-spinner-32 MIT-LICENSE
Octocat-spinner-32 Manifest
Octocat-spinner-32 README.markdown
Octocat-spinner-32 Rakefile
Octocat-spinner-32 VERSION.yml
Octocat-spinner-32 comeback.gemspec
README.markdown

Comeback

Provides a mechanism for storing URLs to return to at a later time. Allows the current URL, a custom URL, or the referer to be stored.

When a referer is stored, it is checked against the current page URL, and if they're the same, then the referer won't be set and the default path will be used instead.

By default, the session key :comeback_to is used to store the URL. The class inheritable accessor comeback_session_key can be set to override this.

Example

In your controller, you first call #store_referer to save the referer to the current page, and then to access it again, call #return_or_redirect_to and pass it the same arguments you would pass to #redirect_to as the default in case a referer has not been set:

class MyController < ApplicationController def first_action store_referer end

def second_action
  return_or_redirect_to root_path
end

end

You can also store the referer using a before filter:

class MyController < ApplicationController before_filter :store_referer, :only => :first_action

def first_action
end

end

The current page URL can also be stored instead of the referer:

class MyController < ApplicationController def first_action store_location redirect_to login_path end end

Explicit URLs may also be stored:

class MyController < ApplicationController def first_action store_location dashbaord_path redirect_to login_path end end

Copyright (c) 2008 Tyler Hunt, released under the MIT license

Something went wrong with that request. Please try again.