3
votes

I have a requirement for the following route setup:

  • /user/:user_id/feed - displays today's feed items
  • /user/:user_id/feed/:date - displays the selected date's feed items

The second route doesn't need it's own controllers, views or templates, all it needs to do is change a property on the first route's controller.

I've tried using multiple dynamic segments in the route but that seems to require that all the segments are passed, even when using route globbing.

How can I have a route with an optional segment at the end or should I be handling this in a completely different way?

1
I ended up working around this by using "/user/:user_id/feed/today" for today's feed items. It would be great to find a proper solution though as this workaround won't work for all situations. - Kevin Ansfield

1 Answers

0
votes

you can define the route path as /user/:user_id/feed/:date,return the object that contains properties user_id and date in serialize method,use the same controller and template used in the route /user/:user_id/feed.I hope this soln solves your problem.