Does to_json require parameters? what about within rails?

Posted by Harry Wood on Stack Overflow See other posts from Stack Overflow or by Harry Wood
Published on 2010-05-14T17:08:39Z Indexed on 2010/05/14 23:04 UTC
Read the original article Hit count: 265

Filed under:
|

Does to_json require parameters? what about within rails?

I started getting the error "wrong number of arguments (0 for 1)" when doing myhash.to_json

Unfortunately I'm not sure when this error started happening, but I guess it relates to some versions of either rails or the json gem. I suppose my code (in a rails controller) is using the ActiveSupport::JSON version of to_json, rather than the to_josn method supported by the json gem. ActiveSupport::JSON vs JSON

In environment.rb I have

RAILS_GEM_VERSION = '2.3.2'

and also

config.gem "json", :version=> '1.1.7'

It's just a simple hash structure containing primitives which I want to convert in my controller, and it was working, but now I can't seem to run to_json without passing parameters.

© Stack Overflow or respective owner

Related posts about ruby-on-rails

Related posts about JSON