Tutorial :ruby uninitialized constant


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      @test1=@hxml.parsetime    end  end  

So what am I doing wrong here?


Don't capitalize "Class" in Ruby.


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

so it should be look like this

require 'rubygems' require 'rexml/document'

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »