私はRABLが本当に好きですが、ビューフォルダが.rabl
ファイルで乱雑になるようです。私は本当に理想的には別のAPI
viewsディレクトリを持ちたいので、次のようになります。
app/
views/
customers/
index.html.erb
show.html.erb
......
api/
v1/
customers/
index.json.rabl
show.json.rabl
これを達成するための最良の方法は何ですか?私はこのチュートリアルを使用しています:
http://railscasts.com/episodes/350-rest-api-versioning
バージョン管理を設定しますが、RABLをサポートしていません。私はこれを試しましたapp/controllers/api/v1/customers_controller.rb
:
module Api
module V1
class CustomersController < ApplicationController
respond_to :json
def index
@customers = Customer.search(params[:page])
Rabl::Renderer.json(@customers, 'api/v1/customers/index')
end
end
end
end
しかし、予想通り、それはうまくいかなかったようです。