4

Im trying to use the rabl templating system from within rails-api.

rabl looks for templates in the view path, which rails-api omits.

How would i setup rabl-rails, i have included the below lines into my Controller.

        include ActionController::MimeResponds
        include ActionController::ImplicitRender
        respond_to :json

However: json: @deal uses standard rails rendered. Renderer.json(@deal) in undefined, i assume it would be available with rabl.

Any help would be appreciated.

theog
  • 2,062
  • 2
  • 14
  • 13

1 Answers1

2

Add:

config.view_paths = ['/app/views']

to config/initializers/rabl_init.rb. No need for rabl-rails, use plain rabl, no need for those include's, no need for respond_to. Render with:

render 'foo/bar' # will render app/views/foo/bar.rabl template
phil pirozhkov
  • 4,740
  • 2
  • 33
  • 40