Rails router gives us an easy way to define optional path parameters, like this:
# config/routes.rb
scope "(:locale)", locale: /ru|de|fr/ do
resources :books
end
Thus we can access /users path and get the default locale, or /ru/books and get the locale in params[:locale].
But with the same setup we can also call the page /books?locale=ru and get the same effect (both path parameters and query string parameters are treated equally and put in the params hash). If locale is processed in a global before_action as Rails i18n guide suggests we can even set locale for the pages that are not supposed to be localized.
So my question is what is the simplest and cleanest way differ path parameters from query string parameters (with the goal to ignore certain query string parameters)?