how/where to declare a global data structure?

I'd like to read a custom config file into a hash at rails startup and
have access to this hash from my controller actions. I wrote a sub to
create the hash in my application controller (wrong place?) but I'm
having trouble accessing the hash from my actions. I'm probably doing
something silly as I'm fairly new to RoR.

Thanks a lot.

Ed wrote:

I'd like to read a custom config file into a hash at rails startup and
have access to this hash from my controller actions. I wrote a sub to
create the hash in my application controller (wrong place?) but I'm
having trouble accessing the hash from my actions. I'm probably doing
something silly as I'm fairly new to RoR.

The application controller seems the right place to put the method to
read in the data. For it to be available to all controllers in their
methods, you probably want to put it into a class variable...

Assuming it's a yaml file, completely untested:

    require "yaml"

    class ApplicationController < ActionController::Base

      MY_CONFIG = YAML.load(File.read(File.join(RAILS_ROOT, "config",
"my_config.yml")))

    end

Now you can simply access MY_CONFIG from all your controllers.