Hello, I have a file that represents all components of a game. I want to load the file into cache on boot, then have the ability to call the attributes of the file from the controllers. How do I begin?
+2
A:
I like http://cobravsmongoose.rubyforge.org for most simple XML handling:
CobraVsMongoose.xml_to_hash(File.open('path/to/xml').gets)
As for your specific case, I would add an initializer which requires cvm and sets the value above to a constant, which you could then access wherever you want...
# config/initializers/load_xml.rb
require 'cobravsmongoose'
MY_XML = CobraVsMongoose.xml_to_hash(File.open('path/to/xml').gets)
floyd
2010-01-24 21:14:38