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


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.


Put it in your Gemfile:

gem ‘json’


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

Posted via

Erol M. Fornoles

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