title: Reload Rails 3 initializer in development mode
body: <p>I'm building a Rails 3 app where users can select one of a number of templates and build a little website. I'm trying to initialize all of the available templates when the application starts. That's essentially a file that let's me define them all, then calls <code>Template.add(template)</code> for each one of them, which in turn stores them in <code>@@templates</code> and I can access them via <code>Template.find(name)</code>.</p>
  
  <p>The problem is that in development mode, the initializer I have making the calls to <code>Template.add</code> are getting loaded on the first request, then wiped out on <code>reload!</code>. I've read about <code>config.to_prepare</code>, but it isn't working for me, likely because I'm requiring the templates like this:</p>
  
  <pre><code># template config at app/templates/template_name/template_name.rb
  path = File.expand_path(Rails.root + 'app/templates')
  Dir[File.join(path, '/*')].each do |template|
    name = File.basename(template)
    require File.join(path, name, "#{name}.rb")
  end
  </code></pre>
  
  <p>What can I do to either reload these files after <code>reload!</code> or keep them from getting trashed at all? Also, if you have a recommendation for a better way to handle this, I'm all ears. I'm still getting my footing with Rails, especially in regards to configuration stuff.</p>
  
  <p><em>I'm temporarily avoiding this problem by loading the data in the class. Save me from this ugly, non-modular nastiness.</em></p>