title: NameError: uninitialized constant ModelName
body: <p>I'm trying to upload some data from a CSV into my db (sqlite3, in rails 4). I followed the steps listed <a href="https://stackoverflow.com/questions/4410794/ruby-on-rails-import-data-from-a-csv-file/4410880#4410880">here</a>, not only the ones included in the first comment, but also the alternative option in the 2nd comment. I'm struggling with a NameError: uninitialized constant Drawing (my Model name).</p>
  
  <p>I have tried to fix it by including config.autoload_paths += %W(#{config.root}/lib) as adviced <a href="https://hackhands.com/rails-nameerror-uninitialized-constant-class-solution/" rel="nofollow noreferrer">here</a>, but no luck. Any idea how to tackle this issue? Don't want to store the CSV file within the app, but exctract its rows and create records in my DB with their values.</p>
  
  <p>lib/tasks/import_drawings_csv.rake</p>
  
  <pre><code>            task :drawing =&gt; :environment do
              require 'csv'    
  
                  csv_text = File.read('path/to/public/imageshello.csv')
                  CSV.foreach("path/to/public/imageshello.csv", :headers =&gt; true) do |row|
                    Drawing.create!(row.to_hash)
                  end
              end
  </code></pre>
  
  <p>terminal trace</p>
  
  <pre><code>            javiers-mbp:colour malditojavi$ rake import_drawings_csv
              rake aborted!
              NameError: uninitialized constant Drawing
              /Users/malditojavi/Desktop/colour/lib/tasks/import_drawings_csv.rake:5:in `block in &lt;top (required)&gt;'
              /Users/malditojavi/Desktop/colour/lib/tasks/import_drawings_csv.rake:4:in `&lt;top (required)&gt;'
              /Users/malditojavi/.rvm/gems/ruby-2.2.0/gems/railties-4.2.0/lib/rails/engine.rb:658:in `load'
              /Users/malditojavi/.rvm/gems/ruby-2.2.0/gems/railties-4.2.0/lib/rails/engine.rb:658:in `block in run_tasks_blocks'
              /Users/malditojavi/.rvm/gems/ruby-2.2.0/gems/railties-4.2.0/lib/rails/engine.rb:658:in `each'
              /Users/malditojavi/.rvm/gems/ruby-2.2.0/gems/railties-4.2.0/lib/rails/engine.rb:658:in `run_tasks_blocks'
              /Users/malditojavi/.rvm/gems/ruby-2.2.0/gems/railties-4.2.0/lib/rails/application.rb:438:in `run_tasks_blocks'
              /Users/malditojavi/.rvm/gems/ruby-2.2.0/gems/railties-4.2.0/lib/rails/engine.rb:453:in `load_tasks'
              /Users/malditojavi/Desktop/colour/Rakefile:6:in `&lt;top (required)&gt;'
              /Users/malditojavi/.rvm/gems/ruby-2.2.0/bin/ruby_executable_hooks:15:in `eval'
              /Users/malditojavi/.rvm/gems/ruby-2.2.0/bin/ruby_executable_hooks:15:in `&lt;main&gt;'
              (See full trace by running task with --trace)
              javiers-mbp:colour malditojavi$ rake import_drawings_csv
  </code></pre>
  
  <p>application.rb</p>
  
  <pre><code>            require File.expand_path('../boot', __FILE__)
  
              require 'rails/all'
  
              # Require the gems listed in Gemfile, including any gems
              # you've limited to :test, :development, or :production.
              Bundler.require(*Rails.groups)
  
              module Colour
                class Application &lt; Rails::Application
                  # new line added for autoloading libs
                  config.autoload_paths += %W(#{config.root}/lib)
                  # Settings in config/environments/* take precedence over those specified here.
                  # Application configuration should go into files in config/initializers
                  # -- all .rb files in that directory are automatically loaded.
  
                  # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
                  # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
                  # config.time_zone = 'Central Time (US &amp; Canada)'
  
                  # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
                  # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
                  # config.i18n.default_locale = :de
  
                  # Do not swallow errors in after_commit/after_rollback callbacks.
                  config.active_record.raise_in_transactional_callbacks = true
                end
              end
  </code></pre>