rake aborted! NameError: uninitialized constant even add :enviroment to task
<p>I'm newbie to RoR and trying to create a task to import database from google spreadsheet by creating an Importer under lib/spreadsheet. but rake cannot find my importer even I added :environment to task according to some others issues in SOF. here are my files</p>

<p>lib/spreadsheet/importer.rb</p>

<pre><code>class SpreadSheet::Importer
  def initialize
    @session = GoogleDrive.saved_session("#{Rails.root}/config/google_drive/config.json")
  end

  def exec(table_name)
    #do something
  end
end
</code></pre>

<p>lib/tasks/spreadsheet.rake</p>

<pre><code>namespace :spreadsheet do
  task :get =&gt; :environment do
    importer = Spreadsheet::Importer.new
    importer.exec
  end
end
</code></pre>

<p>Error:</p>

<blockquote>
  <p>rake aborted!</p>
  
  <p>NameError: uninitialized constant <code>SpreadSheet</code></p>
  
  <p>/home/vagrant/workspace/ruby/kuwata-summer/lib/tasks/spreadsheet.rake:1:in <code>&lt;top (required)&gt;</code></p>
  
  <p>/home/vagrant/workspace/ruby/kuwata-summer/vendor/bundle/ruby/2.3.0
  /gems/railties-5.0.0/lib/rails/engine.rb:654:in <code>block in run_tasks_blocks</code></p>
  
  <p>/home/vagrant/workspace/ruby/kuwata-summer/vendor/bundle/ruby/2.3.0/gems/railties-5.0.0/lib/rails/engine.rb:654:in <code>each</code></p>
  
  <p>/home/vagrant/workspace/ruby/kuwata-summer/vendor/bundle/ruby/2.3.0/gems/railties-5.0.0/lib/rails/engine.rb:654:in <code>run_tasks_blocks</code></p>
  
  <p>/home/vagrant/workspace/ruby/kuwata-summer/vendor/bundle/ruby/2.3.0/gems/railties-5.0.0/lib/rails/application.rb:443:in <code>run_tasks_blocks</code></p>
  
  <p>/home/vagrant/workspace/ruby/kuwata-summer/vendor/bundle/ruby/2.3.0/gems/railties-5.0.0/lib/rails/engine.rb:457:in <code>load_tasks</code></p>
  
  <p>/home/vagrant/workspace/ruby/kuwata-summer/rakefile:6:in <code>&lt;top (required)&gt;</code></p>
  
  <p>/home/vagrant/workspace/ruby/kuwata-summer/vendor/bundle/ruby/2.3.0/gems/rake-11.2.2/exe/rake:27:in <code>&lt;top (required)&gt;</code></p>
  
  <p>/home/vagrant/.rbenv/versions/2.3.1/bin/bundle:23:in <code>load</code></p>
  
  <p>/home/vagrant/.rbenv/versions/2.3.1/bin/bundle:23:in <code>&lt;main&gt;</code></p>
  
  <p>(See full trace by running task with --trace)</p>
</blockquote>