我一直收到这个错误:
未初始化的常量GetxmlController::Xmlparse
我的类代码如下所示
require "rexml/document"
include REXML
Class Xmlparse
def parsetime
xmlfile = File.new("colors.xml")
xmldoc = Document.new(xmlfile)
root = xmldoc.root
return root
end
end我的控制器看起来像:
class GetxmlController < ApplicationController
def findxml
@hxml=Xmlparse.new
@test1=@hxml.parsetime
end
end那么我到底做错了什么呢?
发布于 2010-07-22 12:47:25
在Ruby中不要大写"Class“。
发布于 2010-07-22 15:04:21
尝试在需要"rexml/document“之前需要”rubygems“
所以它应该是这样的
需要'rubygems‘需要'rexml/document’
https://stackoverflow.com/questions/3305771
复制相似问题