Optional part in rails routing path -


i trying create route page can have param1 , param2. param2 optional part , code take default value if value not present. following trying do

match '/school/:dept/:staff/show' => staff#show match '/school/:staff/show' => staff#show 

i have bunch of statements above seems of repetition. there better way this. this link has approach using third party option. considering older post, looking see if supported rails.

as per: http://asciicasts.com/episodes/203-routing-in-rails-3

we can defining route this, directing matching route our info#about action. note can nest parentheses when creating optional parameters.

    match "/:year(/:month(/:day))" => "info#about"   

Comments

Popular posts from this blog

java - Jmockit String final length method mocking Issue -

asp.net - Razor Page Hosted on IIS 6 Fails Every Morning -

c++ - wxwidget compiling on windows command prompt -