0

I am using rabl for my api calls in rails application. Here is my sample code

app.get '/item/:id' do
  @errors = []
  @revisions = []
  request.body.rewind  # in case someone already read it
  @item = Entity.for_owner(params[:id], @user)
  render :rabl, :item_show
end

Instead of rabl I want to use jbuilder how can I render here. I have made the view jbuilder view like this item_show.json.builder

Jbuilder.encode do |json|
  json.id @item.id
  json.account_id @item.account_id
end

Could any one help me how can i render this view. I tried with @item.to_json but it is not rendering jbuilder view.

mraaroncruz
  • 3,780
  • 2
  • 32
  • 31

2 Answers2

3

tilt-jbuilder supports Sinatra since 0.4.0, and I wrote a sample at https://gist.github.com/a2ikm/5072882 . I hope it helps you.

a2ikm
  • 455
  • 5
  • 8
1

Change the extension of the template from .builder to .jbuilder

BSB
  • 1,516
  • 13
  • 14