Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I set default parameter value in routing in 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" 

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

like image 227
Zahid Avatar asked Aug 30 '11 07:08

Zahid


1 Answers

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

More details in the official Rails guides.

like image 62
Simone Carletti Avatar answered Oct 08 '22 19:10

Simone Carletti