Nabe Nabe - 3 months ago 5x
Ruby Question

Ruby: why use # not /?

In the following, what is the reason for having

rather than
? All others are

Rails.application.routes.draw do
root 'static_pages#home'
get 'static_pages/help'
get 'static_pages/about'


This is the full equivalent of the code you provided:

Rails.application.routes.draw do
  get '/',                  to: 'static_pages#home'
  get 'static_pages/help',  to: 'static_pages#help'
  get 'static_pages/about', to: 'static_pages#about'

The hash symbol # divides controller and action names in route destination string.

In your example you use the root method. It is a shorthand for get '/'. So you don't specify the request path.

In the last two rules, destination can be omitted because Rails calculates it automatically.

I suggest that you read the official Rails routing guide. It explains all these things.