user1204730
user1204730

Reputation: 31

Rendering Jbuilder view

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

Answers (2)

a2ikm
a2ikm

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

BSB
BSB

Reputation: 1705

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

Upvotes: 1

Related Questions