I've read this Best practices for API versioning?. And I agree with putting the version in url path rather than in HTTP header.
In order to implement this, I have a namespaced controller like this:
class Api::V1::UsersController < Api::BaseController
def show
...
end
end
And the route are:
current_api_routes = lambda do
resource :users
end
namespace :api do
namespace :v1, ¤t_api_routes
end
Then rake routes
I can get routes like this:
api_v1_user GET /api/v1/users/:id(.:format) api/v1/users#show
...
I want that version v1.2
goes to controller of v1
. Then I can get minor version number in controller like this:
class Api::V1::UsersController < Api::BaseController
def show
minor_version = params[:minor_version] # minor_version = 2
...
end
end
Is there a way to achieve this?