Natus Drew
Natus Drew

Reputation: 1896

Rails Route Constraint

match '/:question_id', :to => 'welcome#dashboard', :via => [:get], constraint: { question_id: /\d+/ }

I don't know why this routing rule is matching paths like

localhost/assets

because I added the numeric constraint to only matching digits.

Upvotes: 0

Views: 185

Answers (1)

Substantial
Substantial

Reputation: 6682

The option is contstraints.

match '/:question_id', :to => 'welcome#dashboard', :via => [:get], constraints: { question_id: /\d+/ }  

Upvotes: 1

Related Questions