In my route file I have some route like below. What this means? I looked in rails route guide but I can not find explanation for => and foo: 'bar'
get '/clients/:status' => 'clients#index', foo: 'bar'
Please explain what this means?
It means that for a HTTP GET request to a URI of pattern /clients/:status
where :status
is the variable parameter.
The => clients#index
stands for Controller#action
where controller
is clients
i.e. ClientsController
and action
is index
.
The third option you have foo: 'bar'
is basically other options to the route definition. Other options such as as
, constraints
and so on.
For example with as
(which lets you name your route):
get '/clients/:status' => 'clients#index', as: :client_status
Here as: :client_status
would replace your foo: 'bar'
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With