0

Jbuilder standalone will not render anything. Do I need a configuration parameter to get it to work in Rails 3.2.8?

1.9.2p320 :257 > Jbuilder
 => Jbuilder 
1.9.2p320 :258 > Jbuilder.new {|json| json.foo 'bar'}.target!
 => "{}" 

Thanks a million.

UPDATE

The encode method works.

1.9.2p320 :016 > Jbuilder.encode {|json| json.foo 'bar'}
 => "{\"Foo\":\"bar\"}" 

But I'd like to use nested Jbuilder objects to construct more complex JSON. The documentation says I should be able to get back a builder object and call target! to get the json string. I'm really quite stumped.

1 Answers1

0

Oops. I was using the documenation on the Github, but using the version of the gem on rubygems.org

replacing:

gem 'jbuilder'

with:

gem 'jbuilder', :git => "https://github.com/rails/jbuilder.git", :tag => "v0.9.1"

in my Gemfile solved the problem.