Rafi Jacoby
2009-Jul-28 01:38 UTC
NoMethodError: undefined method `[]'' for #<JSON::Ext::Generator::State:0x2407ea8>
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. Anyone encounter/conquer this? Tx, Rafi
Rafi Jacoby
2009-Jul-28 16:45 UTC
Re: NoMethodError: undefined method `[]'' for #<JSON::Ext::Generator::State:0x2407ea8>
On Jul 27, 6:38 pm, Rafi Jacoby <rjac...-xqL8Q0s5VTBWk0Htik3J/w@public.gmane.org> 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.
snacktime
2009-Jul-29 05:25 UTC
Re: NoMethodError: undefined method `[]'' for #<JSON::Ext::Generator::State:0x2407ea8>
On Mon, Jul 27, 2009 at 6:38 PM, Rafi Jacoby <rjacoby-xqL8Q0s5VTBWk0Htik3J/w@public.gmane.org> wrote:> > > Anyone encounter/conquer this? >Ya, they changed how parse/generate works I think it accepts/returns arrays now. Changing the behavior of a gem like that is wrong. Can we get this changed back please? Chris --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---