#to_json incompatibilities between ActiveSupport & JSON gems

Kenneth Kalmer
2008-11-26T14:08:35Z

Hi all

Just spotted a issue when using the json & activesupport gems in the same
project. Below is a simple irb session showing the effect:

irb(main):001:0> require ''json''
=> true
irb(main):002:0> Time.now.to_json( nil, 1 )
=> "\"Wed Nov 26 15:56:02 +0200 2008\""
irb(main):003:0> require ''activesupport''
=> true
irb(main):004:0> Time.now.to_json( nil, 1 )
ArgumentError: wrong number of arguments (2 for 1)
        from (irb):4:in `to_json''
        from (irb):4

Searching through the json_pure-1.1.3 code it seems the #to_json signature
is "def to_json(*)", and in activesupport''s Time
it''s def to_json(options nil). Looking through the other activesupport
extensions for JSON it seems
to be the same case.

Any suggestions? Any objections to me diving in and fixing it?

Best