I am developing an application whose backend is written in rails 5 api (beta).
My API will have some versions, and I use this approach to resolve versions:
https://github.com/iamvery/rails-api-example/blob/master/config/routes.rb
Rails.application.routes.draw do
def api_version(version, &routes)
api_constraint = ApiConstraint.new(version: version)
scope(module: "v#{version}", constraints: api_constraint, &routes)
end
api_version(1) do
resources :articles, only: :index
end
api_version(2) do
resources :articles, only: :index
end
end
The fact is that I do not indicate the version, it shows me an error (obviuos) ( ActionController::RoutingError: No route matches [GET] \...).
But I would like to get directions using the latest api instead of throwing an error.
source
share