title: Uninitialized Constant error on Model reference in Rake
body: <p>In my sample_data.rake file, I have the command "<code>Diner.create!(...)</code>" which causes an "<code>uninitialized constant Diner</code>" error.  However, if I execute the same "Diner.create!(...)" command in the Rails console, it is successful.  If I "require" the model in the sample_data.rake file, I get the error "<code>ActiveRecord::ConnectionNotEstablished</code>" with the backtrace showing "<code>active_record/connection_adapters/abstract/connection_pool.rb:318:in retrieve_connection'</code>".  Here is my diner.rb file:</p>
  
  <pre><code>class Diner &lt; ActiveRecord::Base
    has_many  :redemptions
    has_many  :surveys, :through =&gt; :redemptions
  end
  </code></pre>
  
  <p>And the code in the sample_data.rake file that causes the problem is:</p>
  
  <pre><code>99.times do |n|
    gender = rand(1) == 0 ? "male" : "female"
    birthdate = Date.ordinal(DateTime.now.year - 13 - rand(62), rand(364)+1)
    Diner.create!(:gender =&gt; gender, :birthdate =&gt; birthdate)
  end
  </code></pre>
  
  <p>Removing the above code causes the file to process successfully.  And, as I said earlier, the above code works correctly in rails console.</p>