Reputation: 401
I am trying to use RABL to create an API - but my setup is a bit different than the standard setup - as defined in their WIKI.
I have setup an API namespace in my routes:
namespace :api do
resources :orders
end
I have my controller within /app/controllers/api/orders_controller.rb
and my RABL view within /app/views/api/orders/index.json.rabl:
When I try to visit localhost:3000/api/orders, I get the following error:
Template is missing
Missing template api/orders/index with {:handlers=>[:erb, :rjs, :builder, :rhtml, :rxml, :haml, :rabl], :formats=>[:html], :locale=>[:en, :en]} in view paths
However, If I create a new file called '/app/views/api/orders/index.html.erb' The view renders - but doesn't use RABL.
How can I make it so that it uses RABL?
Thanks
Upvotes: 4
Views: 963
Reputation: 16287
It is looking for the "html" format. Try adding .json
extension to the URL or changing your routes to this.
namespace :api, defaults: {format: 'json'} do
resources :orders
end
Upvotes: 6