redirect

redirect(*args, &block) Instance Public methods Redirect any path to another path: get "/stories" => redirect("/posts") You can also use interpolation in the supplied redirect argument: get 'docs/:article', to: redirect('/wiki/%{article}') Note that if you return a path without a leading slash then the url is prefixed with the current SCRIPT_NAME environment variable. This is typically '/' but may be different in a mounted engine or where the application is deployed to a s

polymorphic_url

polymorphic_url(record_or_hash_or_array, options = {}) Instance Public methods Constructs a call to a named RESTful route for the given record and returns the resulting URL string. For example: # calls post_url(post) polymorphic_url(post) # => "http://example.com/posts/1" polymorphic_url([blog, post]) # => "http://example.com/blogs/1/posts/1" polymorphic_url([:admin, blog, post]) # => "http://example.com/admin/blogs/1/posts/1" polymorphic_url([user, :blog, post]) # => "

polymorphic_path

polymorphic_path(record_or_hash_or_array, options = {}) Instance Public methods Returns the path component of a URL for the given record. It uses polymorphic_url with routing_type: :path.

path

path(params, request) Instance Public methods

inspect

inspect() Instance Public methods

normalize_path

normalize_path(path) Class Public methods Invokes Journey::Router::Utils.normalize_path and ensure that (:locale) becomes (/:locale) instead of /(:locale). Except for root cases, where the latter is the correct one.

normalize_name

normalize_name(name) Class Public methods

scope

scope(*args) Instance Public methods Scopes a set of routes to the given default options. Take the following route definition as an example: scope path: ":account_id", as: "account" do resources :projects end This generates helpers such as account_projects_path, just like resources does. The difference here being that the routes generated are like /:account_id/projects, rather than /accounts/:account_id/projects. Options Takes same options as Base#match and Resources#resources.

namespace

namespace(path, options = {}) Instance Public methods Scopes routes to a specific namespace. For example: namespace :admin do resources :posts end This generates the following routes: admin_posts GET /admin/posts(.:format) admin/posts#index admin_posts POST /admin/posts(.:format) admin/posts#create new_admin_post GET /admin/posts/new(.:format) admin/posts#new edit_admin_post GET /admin/posts/:id/edit(.:format) admin/posts#ed

defaults

defaults(defaults = {}) Instance Public methods Allows you to set default parameters for a route, such as this: defaults id: 'home' do match 'scoped_pages/(:id)', to: 'pages#show' end Using this, the :id parameter here will default to 'home'.