Rails 3 API with RABL

I am trying to use RABL to create an API, but my setup is slightly different from the standard setup - as defined in their WIKI.

I set the API namespace on my routes:

namespace :api do resources :orders end 

I have my controller in / app / controllers / api / orders _controller.rb

and my RABL view in /app/views/api/orders/index.json.rabl:

When I try to visit localhost: 3000 / api / orders, I get the following error:

Missing template

 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', it renders the view, but does not use RABL.

How can I make it use RABL?

thanks

+4
source share
1 answer

He is looking for the "html" format. Try adding the .json extension to the URL or change the routes to this.

 namespace :api, defaults: {format: 'json'} do resources :orders end 
+6
source

All Articles