I am building web API with Grape gem on Ruby on Rails 4.1, with their 'version' function.
Sample code here.
# app/api/api.rb
class API < Grape::API
prefix 'api'
format :json
formatter :json, Grape::Formatter::Rabl
default_format :json
mount V1::Root
end
# app/api/v1/root.rb
module V1
class Root < Grape::API
version 'v1'
resource :users, rabl: "users" do
get '/' do
@users = User.all
end
end
end
end
# config/routes.rb
mount API => "/"
with these code, app/views/api/users.rabl
is used for view template on request to http://localhost:3000/api/v1/users
.
I want to use template in app/views/api/v1
for v1
request. Is there any way to do that ?
current
/api/v1/users
->app/views/api/users.rabl
/api/v2/users
->app/views/api/users.rabl
want
/api/v1/users
->app/views/api/v1/users.rabl
/api/v2/users
->app/views/api/v2/users.rabl