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
Post a Comment