title: Accessing Rails environment config in Rake namespace
body: <p>I have a path defined in my <code>environment.rb</code> file</p>
  
  <pre><code>MyRailsApp::Application.configure do
    config.xml_import_path = "/path/to/xml"
  end
  </code></pre>
  
  <p>I'd like to be able to set a variableaccess these within a Rake file like this</p>
  
  <pre><code>namespace :myapp do
    xml_path = MyRailsApp::Application.config.xml_import_path
  
    task :first_task =&gt; :environment do
      # do some stuff with xml_path
    end
  
    task :second_task =&gt; :environment do
      # do some other stuff with xml_path
    end
  end
  </code></pre>
  
  <p>but I keep getting an error when I run <code>rake myapp:first_task</code></p>
  
  <pre><code>undefined method `xml_import_path' for #&lt;Rails::Application::Configuration:0x00000006a98bd8&gt;
  </code></pre>
  
  <p>I guess it's something to do with the environment no being loaded, as it works if I put</p>
  
  <pre><code>xml_path = MyRailsApp::Application.config.xml_import_path
  </code></pre>
  
  <p>inside the task definition.</p>
  
  <p>Is there any way to use config values set in <code>environment.rb</code> like I am attempting to do?</p>
  
  <p>Is there a better/right way to do it?</p>
  
  <p>cheers,</p>
  
  <p>Luke</p>