Use polymorphic association for routing, and change logic to model instead of view.