Topic: unable to use json
Hi Folks,
I am a new bie to Json, and tried implementing in my rails app.
I installed the pure ruby version of json(json_pure 1.1.2) and my rails is 2.0
In my environment.rb, I have
require 'json/pure'
In my controller, when I tried this simple bit of code,
item = Item.find(1)
item.to_jon
I got the following error:
ArgumentError (wrong number of arguments (2 for 1)):
c:/ruby/lib/ruby/gems/1.8/gems/json_pure-1.1.2/lib/json/pure/generator.rb:251:in `to_json'
c:/ruby/lib/ruby/gems/1.8/gems/json_pure-1.1.2/lib/json/pure/generator.rb:251:in `json_transform'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/attribute_methods.rb:160:in `map'
c:/ruby/lib/ruby/gems/1.8/gems/json_pure-1.1.2/lib/json/pure/generator.rb:245:in `each'
c:/ruby/lib/ruby/gems/1.8/gems/json_pure-1.1.2/lib/json/pure/generator.rb:245:in `map'
c:/ruby/lib/ruby/gems/1.8/gems/json_pure-1.1.2/lib/json/pure/generator.rb:245:in `json_transform'
c:/ruby/lib/ruby/gems/1.8/gems/json_pure-1.1.2/lib/json/pure/generator.rb:218:in `to_json'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/serializers/json_serializer.rb:67:in `serialize'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/serialization.rb:91:in `to_s'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/serializers/json_serializer.rb:57:in `to_json'
What might be th reason? Any help much appreciated...
thanks and regards
Venkat