如何在rails 3中的路由中设置默认参数值

时间:2011-08-30 07:33:58

标签: ruby-on-rails ruby-on-rails-3 routes

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

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

我希望将方向值默认为next

1 个答案:

答案 0 :(得分:38)

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

official Rails guides

中的更多详细信息