Without adding "Rails.root.join(...)" (or something else returning a complete path to the countries.xml file) this error occurred:
"No such file or directory @ rb_sysopen - config/countries.xml"
I think it happened because it could not find that file through a relative path.
def self.load_countries
countries = {}
- xml = REXML::Document.new(File.read("config/countries.xml"))
+ xml = REXML::Document.new(File.read(Rails.root.join("config", "countries.xml")))
xml.elements.each("geonames/country") do |ele|
code = ele.get_text("countryCode").to_s