views:

58

answers:

2

I keep getting this error:

uninitialized constant GetxmlController::Xmlparse

my code for the class looks like

  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

my controller looks like:

class GetxmlController < ApplicationController
def findxml
@hxml=Xmlparse.new
@[email protected]
end
end

So what am I doing wrong here?

+1  A: 

Don't capitalize "Class" in Ruby.

Chuck
Um, anyone care to explain the downvote? AFAICT, this *is* why that constant is undefined.
Chuck
+1 - that at least levels it out
Geoff Lanotte
good catch had to make this a module in order for the controller to see it
Anthony
+1  A: 

Hi Anthony

try require 'rubygems' before require "rexml/document"

so it should be look like this

require 'rubygems' require 'rexml/document'

sameera207