dewski / json_builder

Rails provides an excellent XML Builder by default to build RSS and ATOM feeds, but nothing to help you build complex and custom JSON data structures. JSON Builder is here to help.
http://garrettbjerkhoel.com/json_builder/
MIT License
244 stars 52 forks source link

uninitialized constant JSONBuilder::Compiler::JSON #27

Closed inconduit closed 12 years ago

inconduit commented 12 years ago

i'm new to rails so this is probably my own issue and not json_builder's but i don't know where else to look.

trying to render some json and i get uninitialized constant JSONBuilder::Compiler::JSON. i'm using rails 2.3.14 and ruby 1.8.7, installed using bundler and i'm also using RVM.

this is getting thrown from a json_builder view. i've pasted the trace below. can anyone suggest what i might have done wrong? is the json_builder gem compatiable with this old version of rails? thanks in advance.

/Users/inconduit/.rvm/gems/ruby-1.8.7-p358/gems/activesupport-2.3.14/lib/active_support/dependencies.rb:131:in `const_missing'
/Users/inconduit/.rvm/gems/ruby-1.8.7-p358/gems/json_builder-3.1.3/lib/json_builder/compiler.rb:147:in `pretty_print'
/Users/inconduit/.rvm/gems/ruby-1.8.7-p358/gems/json_builder-3.1.3/lib/json_builder/compiler.rb:137:in `include_callback'
/Users/inconduit/.rvm/gems/ruby-1.8.7-p358/gems/json_builder-3.1.3/lib/json_builder/compiler.rb:117:in `finalize'
/Users/inconduit/.rvm/gems/ruby-1.8.7-p358/gems/json_builder-3.1.3/lib/json_builder/compiler.rb:17:in `generate'
/Users/inconduit/rails/goviso/app/views/asset_links/index.json_builder:2:in `_run_json_builder_app47views47asset_links47index46json_builder'
/Users/inconduit/rails/goviso/app/controllers/asset_links_controller.rb:30:in `index'
/Users/inconduit/rails/goviso/app/controllers/asset_links_controller.rb:17:in `index'
dewski commented 12 years ago

I'm using the same version of Ruby, Rails, and JSONBuilder as you but cannot reproduce the issue.

➜  old_rails  ruby -v
ruby 1.8.7 (2012-02-08 patchlevel 358) [i686-darwin11.3.0]
➜  old_rails  rails -v
Rails 2.3.14
➜  old_rails  gem list json_builder

*** LOCAL GEMS ***

json_builder (3.1.3)
➜  old_rails  curl http://localhost:3000/jobs.json
{
  "hello": "world"
}

Could you try setting Pretty Print to false and tell me if that works? Put this in config/environments/development.rb:

config.action_view.pretty_print_json = false
inconduit commented 12 years ago

hey, thanks for the response. i have since moved to rabl and uninstalled JSONBuilder. i don't have that environment available anymore, but again thanks for the response.

On 2012-07-04, at 3:51 PM, Garrett Bjerkhoel wrote:

I'm using the same version of Ruby, Rails, and JSONBuilder as you but cannot reproduce the issue.

➜  old_rails  ruby -v
ruby 1.8.7 (2012-02-08 patchlevel 358) [i686-darwin11.3.0]
➜  old_rails  rails -v
Rails 2.3.14
➜  old_rails  gem list json_builder

*** LOCAL GEMS ***

json_builder (3.1.3)
➜  old_rails  curl http://localhost:3000/jobs.json
{
 "hello": "world"
}

Could you try setting Pretty Print to false and tell me if that works? Put this in config/environments/development.rb:

config.action_view.pretty_print_json = false

Reply to this email directly or view it on GitHub: https://github.com/dewski/json_builder/issues/27#issuecomment-6766783

dewski commented 12 years ago

Since I am unable to reproduce it locally, it would be awesome if you could quickly add the json_builder gem back to your app (alongside RABL), and create a test view. You may need to rename the rabl view temporarily. Would like to make sure others don't run into this in the future while using json_builder.

_app/views/folder/index.json.jsonbuilder

hello "world"
inconduit commented 12 years ago

i have a different environment set up now so i can't do that easily. i was using RVM and i think i had a misconfiguration there as i was very new to rails. i'm pretty sure it was something specific to my mangled use of rvm and gemsets.

On 2012-07-04, at 4:01 PM, Garrett Bjerkhoel wrote:

Since I am unable to reproduce it locally, it would be awesome if you could quickly add the json_builder gem back to your app (alongside RABL), and create a test view. You may need to rename the rabl view temporarily. Would like to make sure others don't run into this in the future while using json_builder.

_app/views/folder/index.json.jsonbuilder

hello "world"

Reply to this email directly or view it on GitHub: https://github.com/dewski/json_builder/issues/27#issuecomment-6766894

dewski commented 12 years ago

Thanks for your time, if you ever have time to reproduce this that'd be awesome. Thanks again.