Set up rabl for Ruby on Rails
Clone this wiki locally
Setting up rabl on a Ruby on Rails project is fairly easy. Infact it's as easy as 1..2..3:
rabl to your
Set up your controller to respond to json. You can do this with
render, whatever you fancy.
class Api::ToursController < ApplicationController respond_to :json def index @tours = Tour.all end end
Now, just add a template with the
.rabl extension matching your controller action. For instance, in our example, the template is located at
index.json.rabl is where you pull all of this stuff. For instance:
Refer to rabl's doc for more information on usage.