0.01
No release in over 3 years
Low commit activity in last 3 years
Better back URL for your Rails applications.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 0

Runtime

>= 0
 Project Readme

awesome_back_url

RailsJazz https://www.patreon.com/igorkasyanchuk Listed on OpenSource-Heroes.com

Redirect to proper back URL for your Rails applications. In case if you want to redirect user not to "edit" or "new" page from "show" after creation, but to "index" or other specific URL.

Usage

Options:

awesome_back_path(path = request.referrer, only: nil, except: nil, fallback: :back)
  • "path" - destination to redirect user
  • "only" - regexp of allowed paths
  • "except" - regexp of disallowed paths
  • "fallback" - if path is incorrect (not allowed or not in allowed) redirect to this url.

Samples:

link_to 'Back', awesome_back_path(except: /\/new|\/edit/, fallback: users_path) # returns '/users'
link_to 'Back', awesome_back_path('/path', except: /\/new/, fallback: '/users') # returns  '/path'
link_to 'Back', awesome_back_path('/path/new', except: /\/new|\/edit/, fallback: '/users') # returns '/users'
link_to 'Back', awesome_back_path('/path/edit', except: /\/new|\/edit/, fallback: '/users') # returns '/users'
link_to 'Back', awesome_back_path('/path', only: /\/new|\/edit/, fallback: '/users') # returns '/users'
link_to 'Back', awesome_back_url('/path', fallback: '/users') # returns '/path'    

Installation

Add this line to your application's Gemfile:

gem 'awesome_back_url'

And then execute:

$ bundle

Contributing

You are welcome to contribute.

License

The gem is available as open source under the terms of the MIT License.