Tôi thực sự thích RABL, nhưng có vẻ như nó sẽ làm lộn xộn các thư mục xem của tôi với các tệp .rabl
. Tôi thực sự muốn lý tưởng có một thư mục API
quan điểm riêng biệt nên nó sẽ là như thế này:Thư mục xem RABL API?
app/
views/
customers/
index.html.erb
show.html.erb
......
api/
v1/
customers/
index.json.rabl
show.json.rabl
cách tốt nhất để đạt được điều này là gì? Tôi đang sử dụng hướng dẫn này:
http://railscasts.com/episodes/350-rest-api-versioning
Để thiết lập phiên bản nhưng nó không hỗ trợ RABL. Tôi đã thử điều này trong 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
Nhưng như mong đợi dường như không hoạt động.
Phiên bản này xử lý như thế nào? – toobulkeh