Reputation: 1923
I have a route here:
get 'api/users/:id/friends/:fid', to: 'friends#show'
I want to make the :fid
as optional parameter. Any Ideas?
Upvotes: 1
Views: 51
Reputation: 4515
just put it in parenthesis
get 'api/users/:id/friends(/:fid)', to: 'friends#show'
more information in guideline (paragraph 3.1) http://guides.rubyonrails.org/routing.html
Upvotes: 6
Reputation:
Please try the code as below:
get 'api/users/:id/friends(/:fid)', to: 'friends#show'
Upvotes: 4