Defining your route in this way will have the probably unintended effect
of
shortcircuiting your default routes (i.e. “:controller/:action”). If
that
doesn’t matter to you, then stick with the simplest option. But you can
also put a condition on the parameters like this:
This should now only match in situations where you’ve got numeric
parameters passed for both book_id and page_id.
However…
You should understand that by doing it this way you’re draining your
URLs of
any semantic meaning and search engines will probably not know what to
make
of them. Best practice is generally to provide as many hints in your
anchors as to what’s being linked to, if not in the link text itself
then at
least in the URLs. So unless you’re building an API and you don’t care
about Google juice, I’d stick with the more traditional way of doing
things.
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.