make a route in Rails 3 that takes an id or not
How do I开发者_如何学Python make a route that accepts an id or not
Here is my route:
match '/cancel_greeting/:id', :to => "greetings#cancel", :as => :cancel_greeting
I want it to work if there is an id present or not.
How can I do this?
Thanks
It becomes optional if you put the :id
in paranthesis like this:
match '/cancel_greeting(/:id)', :to => "greetings#cancel", :as => :cancel_greeting
精彩评论