On Jul 27, 6:38 pm, Rafi Jacoby <[email protected]> wrote:
> Trying to move a project to Rails 2.3.3, and getting the following:
>
> NoMethodError: undefined method `[]' for #<JSON::Ext::Generator::State:
> 0x2407ea8>
>         from /Library/Ruby/Gems/1.8/gems/activesupport-2.3.3/lib/
> active_support/json/encoders/hash.rb:45:in `as_json'
>         from /Library/Ruby/Gems/1.8/gems/activesupport-2.3.3/lib/
> active_support/json/encoders/hash.rb:34:in `to_json'
>
> I understand that the to_json/as_json stuff changed, but this is for
> something simple (using just hashes) like:
>
>   JSON.generate({"foo"=>"bar"})
>
> I'm using latest json gem, tried requiring active_support before json,
> and put this into my environment as suggested by the Rails upgrade
> notes:
>
>   ActiveSupport::JSON.backend = 'JSONGem'
>
> No dice.
> If I use Rails 2.3.2, it's happy.

After sleeping on it for a night, I replaced all instance of
'JSON.generate(hash)' with hash.to_json, solving the problem.

Posting this for posterity and those googling the issue.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to