hi , all under rails 2.0
aotianlong@aotianlong:~/workspace/killer$ ruby script/console Loading development environment (Rails 2.0.1)
{:user=>"aotianlong"}.to_json
=> "{\"user\": \"aotianlong\"}"
user = User.find :first
=> #<User id: 1, uname: "aotianlong">
user.to_json
=> "{\"attributes\": {\"id\":1,\"uname\": \"aotianlong\"}}"
{:user=>user}.to_json
ArgumentError: wrong number of arguments (1 for 0) from /usr/lib/ruby/gems/1.8/gems/activesupport-2.0.1/lib/active_support/json/encoding.rb:22:in `to_json' from /usr/lib/ruby/gems/1.8/gems/activesupport-2.0.1/lib/active_support/json/encoding.rb:22:in `send' from /usr/lib/ruby/gems/1.8/gems/activesupport-2.0.1/lib/active_support/json/encoding.rb:22:in `encode' from /usr/lib/ruby/gems/1.8/gems/activesupport-2.0.1/lib/active_support/json/encoding.rb:32:in `raise_on_circular_reference' from /usr/lib/ruby/gems/1.8/gems/activesupport-2.0.1/lib/active_support/json/encoding.rb:21:in `encode' from /usr/lib/ruby/gems/1.8/gems/activesupport-2.0.1/lib/active_support/json/encoders/hash.rb:45:in `to_json' from /usr/lib/ruby/gems/1.8/gems/activesupport-2.0.1/lib/active_support/json/encoders/hash.rb:44:in `map' from /usr/lib/ruby/gems/1.8/gems/activesupport-2.0.1/lib/active_support/json/encoders/hash.rb:44:in `to_json' from /usr/lib/ruby/gems/1.8/gems/activesupport-2.0.1/lib/active_support/core_ext/object/misc.rb:28:in `returning' from /usr/lib/ruby/gems/1.8/gems/activesupport-2.0.1/lib/active_support/json/encoders/hash.rb:43:in `to_json' from (irb):4
how let {:user=>user}.to_json work correct?
thanks for reply.