开发者

make a route in Rails 3 that takes an id or not

开发者 https://www.devze.com 2023-03-27 15:20 出处:网络
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

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
0

精彩评论

暂无评论...
验证码 换一张
取 消