Cannot load JSON in Rails 3

I am converting my app from Rails 2 to Rails 3 and I’m using JSON to
parse text. Now, I never had to require anything in Rails 2, so I
suppose JSON was built in. However, Rails 3 can’t find it by default
(uninitialized constant), so seem to have to manually require it. Any
ideas where should I find it? That is, what path/filename should I
require?

Thanks!

First you need to have the json gem installed, which I assume you do and
then require it. You can do this in config/environment.rb
Use config.gem ‘json’

That’s all.

I suggest you look into using bundler to manage your gems.

Luis

http://www.saffie.ca

Put it in your Gemfile:

gem ‘json’

HTH

On Tue, Oct 19, 2010 at 4:21 AM, Albus D.
[email protected]wrote:

Posted via http://www.ruby-forum.com/.


Erol M. Fornoles
http://erolfornoles.posterous.com
http://github.com/Erol
http://twitter.com/erolfornoles
http://ph.linkedin.com/in/erolfornoles

Thanks, guys!
I only had to write ActiveSupport::JSON, instead of JSON and that’s all.
Thanks, again!

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs