我只是想在我的RVM Ruby 1.9.2安装上运行一个非常简单的代码片段:
require 'rubygems'
require 'active_support'
obj = {"foo" => "bar"}
xml = obj.to_xml
Ruby抱怨如下:
NoMethodError: undefined method `to_xml' for {"foo"=>"bar"}:Hash
from (irb):2
from /Users/.../.rvm/rubies/ruby-1.9.2-p320/bin/irb:16:in `<main>'
为什么会这样?不是to_xml哈希方法吗?
答案 0 :(得分:1)
要求:
require "active_support/all"