Skip to content
Search

Rails:Route

lastmod 2018-08-17created 2015-12-105 edits

List of route

You can check the list of routes with the command below.

$ rake routes

root method

Code like the following is used for routing.

root to: 'home#index'

This uses the root function of the Base module as a Mixin. For reference, below is the content of that code. 1

module Base
    # ...
    def root(options = {})
        match '/', { :as => :root, :via => :get }.merge!(options)
    end
    # ...
end

So, rewritten syntactically, it is equivalent to the following.

root({to: 'home#index'})

For reference, to: uses a Symbol.

See also

References


  1. On MAC OSX, it is located at /Library/Ruby/Gems/2.0.0/gems/actionpack-4.2.5/lib/action_dispatch/routing/mapper.rb. ↩