Reputation: 31
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.
Upvotes: 0
Views: 1262
Reputation: 455
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.
Upvotes: 3