如何在Rails 3的布线中设置默认参数值

问题描述:

如何在Rails 3的路由中设置默认参数值。
例如,我有此路由

How can I set default parameter value in routing in Rails 3. For example I have this route

match ':slug/:id/:direction' => 'quiz#show', :as => :quiz_details, :direction => "next"

,而我想将direction的值默认为 next

and I want to default the value of direction to next.

match ':slug/:id/:direction' => 'quiz#show', :as => :quiz_details, :defaults => { :direction => "next" }

更多详细信息,请参见 Rails官方指南

More details in the official Rails guides.