add example to use template #16

Closed
gfrancesco opened this Issue Dec 3, 2012 · 2 comments

Projects

None yet

2 participants

@gfrancesco

Thanks for the great work, can you please give me a hint on how to integrate Rabl (https://github.com/nesquena/rabl)?
I've ActiveRecord running, but I'm quite stuck at adding templates/controllers.

thanks

@gfrancesco

Found a way, just anybody needs Rabl with ActiveRecord:

  • add rabl to your Gemfile
  • add in lib/app.rb:
require 'rabl'
Rabl.register!
  • as service implementation:
service.implementation do
  @foo = Car.find(params[:id])
  Rabl::Renderer.json(@foo, 'cars', view_path: 'views')
end
  • put your cars.rabl template under views/
@gfrancesco gfrancesco closed this Dec 4, 2012
@mattetti
Owner
mattetti commented Dec 4, 2012

Thanks for finding the solution and posting it here. I don't use Rabl but I'm glad to see you got it working.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment