That documentation is somewhat misleading, isn't it. It is a poor example. The comment about passing symbols to match is a general comment, and should be outside the section on singular resources.
Indeed if you try it stand-alone, you will get the following error when starting Rails or running rake routes
:
rake routes
rake aborted!
missing :controller
So you would have to add a :controller
option for that to work outside of a resource declaration:
get 'profile', to: :show, controller: 'users'
The syntax they specify IS valid inside of a resources
or resource
declaration, e.g.:
resources :user do
collection do
get 'profile', to: :show
end
end
or
resource :user do
get 'profile', to: :show
end
However both those examples generate different routes from the prior example. So again, I think the comment is misplaced.