开发者

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
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜