The file name that you try to open is not a valid one, as the error
describe to you.
You should give a valid path to the desired file.
Since it is a Rails application you should build the path in this
fashion:
class Oxml
def read_xml()
xml = REXML::Document.new(File.open(“#{RAILS_ROOT}/images/
guitars.xml”))
end
end
(There’s no actual need for the temp variable, I just thought it
looked clearer)
‘/images/guitars.xml’ tells file open to look in ‘/images’ (as in,
anchored to the root directory for the system) for guitars.xml.
File.join( ) makes a full path out of the arguments you give it.
RAILS_ROOT is a constant set by rails as the root directory of the
project.
Regards
jon
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.