holden
holden

Reputation: 13581

rails 3 routing question

This is probably quite simple, but how can I make a params optional?

resources :places
match 'register/:id' => 'places#new', :as => :register

currently... it breaks if the :id is not passed which most of the time it won't be.

<%= link_to "Place Sign Up", register_path %> 

Upvotes: 2

Views: 78

Answers (1)

Casual Coder
Casual Coder

Reputation: 1492

Look at the last line of config/routes.rb

match ':controller(/:action(/:id(.:format)))'

it uses () to make a param optional, in your case:

'register(/:id)'

Upvotes: 4

Related Questions