title: rake db:migrate name error undefined method
body: <p>Im struggling trying to make work a ruby on rails project of a friend in my computer. I'm currently working in ubuntu 12.04.</p>
  
  <p>After setting up everything I got an error that I couldn't find anywhere. Here is the error message and the <code>importer.rb</code> file.</p>
  
  <p>Any help would be great.</p>
  
  <p>ERROR MESSAGE</p>
  
  <pre><code>developer@developer-VirtualBox:~/finantec$ rake db:migrate --trace
  ** Invoke db:migrate (first_time)
  ** Invoke environment (first_time)
  ** Execute environment
  rake aborted!
  NameError: undefined method `context' for class `Importr::Importer'
  /home/developer/finantec/vendor/engines/importr/lib/importr/importer.rb:15:in `alias_method'
  /home/developer/finantec/vendor/engines/importr/lib/importr/importer.rb:15:in `&lt;class:Importer&gt;'
  /home/developer/finantec/vendor/engines/importr/lib/importr/importer.rb:4:in `&lt;module:Importr&gt;'
  /home/developer/finantec/vendor/engines/importr/lib/importr/importer.rb:3:in `&lt;top (required)&gt;'
  /home/developer/finantec/app/importers/financial_institution_importer.rb:1:in `&lt;top (required)&gt;'
  /home/developer/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/gems/2.0.0/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:424:in `load'
  /home/developer/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/gems/2.0.0/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:424:in `block in load_file'
  /home/developer/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/gems/2.0.0/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:616:in `new_constants_in'
  /home/developer/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/gems/2.0.0/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:423:in `load_file'
  /home/developer/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/gems/2.0.0/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:324:in `require_or_load'
  /home/developer/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/gems/2.0.0/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:463:in `load_missing_constant'
  /home/developer/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/gems/2.0.0/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:184:in `const_missing'
  /home/developer/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/gems/2.0.0/gems/activesupport-4.0.2/lib/active_support/inflector/methods.rb:226:in `const_get'
  /home/developer/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/gems/2.0.0/gems/activesupport-4.0.2/lib/active_support/inflector/methods.rb:226:in `block in constantize'
  /home/developer/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/gems/2.0.0/gems/activesupport-4.0.2/lib/active_support/inflector/methods.rb:224:in `each'
  /home/developer/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/gems/2.0.0/gems/activesupport-4.0.2/lib/active_support/inflector/methods.rb:224:in `inject'
  /home/developer/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/gems/2.0.0/gems/activesupport-4.0.2/lib/active_support/inflector/methods.rb:224:in `constantize'
  /home/developer/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/gems/2.0.0/gems/activesupport-4.0.2/lib/active_support/core_ext/string/inflections.rb:66:in `constantize'
  /home/developer/finantec/vendor/engines/importr/lib/importr/active_admin.rb:8:in `data_import_interface'
  /home/developer/finantec/app/admin/financial_institution.rb:4:in `block in &lt;top (required)&gt;'
  /home/developer/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/gems/2.0.0/bundler/gems/active_admin-ee996b09edb9/lib/active_admin/dsl.rb:15:in `instance_exec'
  /home/developer/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/gems/2.0.0/bundler/gems/active_admin-ee996b09edb9/lib/active_admin/dsl.rb:15:in `run_registration_block'
  /home/developer/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/gems/2.0.0/bundler/gems/active_admin-ee996b09edb9/lib/active_admin/namespace.rb:223:in `parse_registration_block'
  /home/developer/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/gems/2.0.0/bundler/gems/active_admin-ee996b09edb9/lib/active_admin/namespace.rb:48:in `register'
  /home/developer/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/gems/2.0.0/bundler/gems/active_admin-ee996b09edb9/lib/active_admin/application.rb:120:in `register'
  /home/developer/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/gems/2.0.0/bundler/gems/active_admin-ee996b09edb9/lib/active_admin.rb:76:in `register'
  /home/developer/finantec/app/admin/financial_institution.rb:1:in `&lt;top (required)&gt;'
  /home/developer/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/gems/2.0.0/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:223:in `load'
  /home/developer/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/gems/2.0.0/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:223:in `block in load'
  /home/developer/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/gems/2.0.0/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:214:in `load_dependency'
  /home/developer/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/gems/2.0.0/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:223:in `load'
  /home/developer/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/gems/2.0.0/bundler/gems/active_admin-ee996b09edb9/lib/active_admin/application.rb:179:in `load'
  /home/developer/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/gems/2.0.0/bundler/gems/active_admin-ee996b09edb9/lib/active_admin/application.rb:171:in `block in load!'
  /home/developer/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/gems/2.0.0/bundler/gems/active_admin-ee996b09edb9/lib/active_admin/application.rb:171:in `each'
  /home/developer/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/gems/2.0.0/bundler/gems/active_admin-ee996b09edb9/lib/active_admin/application.rb:171:in `load!'
  /home/developer/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/gems/2.0.0/bundler/gems/active_admin-ee996b09edb9/lib/active_admin/application.rb:195:in `routes'
  /home/developer/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/gems/2.0.0/bundler/gems/active_admin-ee996b09edb9/lib/active_admin.rb:80:in `routes'
  /home/developer/finantec/config/routes.rb:9:in `block in &lt;top (required)&gt;'
  /home/developer/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/gems/2.0.0/gems/actionpack-4.0.2/lib/action_dispatch/routing/route_set.rb:341:in `instance_exec'
  /home/developer/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/gems/2.0.0/gems/actionpack-4.0.2/lib/action_dispatch/routing/route_set.rb:341:in `eval_block'
  /home/developer/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/gems/2.0.0/gems/actionpack-4.0.2/lib/action_dispatch/routing/route_set.rb:319:in `draw'
  /home/developer/finantec/config/routes.rb:3:in `&lt;top (required)&gt;'
  /home/developer/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/gems/2.0.0/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:223:in `load'
  /home/developer/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/gems/2.0.0/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:223:in `block in load'
  /home/developer/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/gems/2.0.0/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:214:in `load_dependency'
  /home/developer/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/gems/2.0.0/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:223:in `load'
  /home/developer/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/gems/2.0.0/gems/railties-4.0.2/lib/rails/application/routes_reloader.rb:40:in `block in load_paths'
  /home/developer/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/gems/2.0.0/gems/railties-4.0.2/lib/rails/application/routes_reloader.rb:40:in `each'
  /home/developer/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/gems/2.0.0/gems/railties-4.0.2/lib/rails/application/routes_reloader.rb:40:in `load_paths'
  /home/developer/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/gems/2.0.0/gems/railties-4.0.2/lib/rails/application/routes_reloader.rb:16:in `reload!'
  /home/developer/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/gems/2.0.0/gems/railties-4.0.2/lib/rails/application/routes_reloader.rb:26:in `block in updater'
  /home/developer/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/gems/2.0.0/gems/activesupport-4.0.2/lib/active_support/file_update_checker.rb:75:in `call'
  /home/developer/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/gems/2.0.0/gems/activesupport-4.0.2/lib/active_support/file_update_checker.rb:75:in `execute'
  /home/developer/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/gems/2.0.0/gems/railties-4.0.2/lib/rails/application/routes_reloader.rb:27:in `updater'
  /home/developer/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/gems/2.0.0/gems/railties-4.0.2/lib/rails/application/routes_reloader.rb:6:in `execute_if_updated'
  /home/developer/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/gems/2.0.0/gems/railties-4.0.2/lib/rails/application/finisher.rb:69:in `block in &lt;module:Finisher&gt;'
  /home/developer/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/gems/2.0.0/gems/railties-4.0.2/lib/rails/initializable.rb:30:in `instance_exec'
  /home/developer/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/gems/2.0.0/gems/railties-4.0.2/lib/rails/initializable.rb:30:in `run'
  /home/developer/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/gems/2.0.0/gems/railties-4.0.2/lib/rails/initializable.rb:55:in `block in run_initializers'
  /home/developer/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/tsort.rb:150:in `block in tsort_each'
  /home/developer/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/tsort.rb:183:in `block (2 levels) in each_strongly_connected_component'
  /home/developer/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/tsort.rb:219:in `each_strongly_connected_component_from'
  /home/developer/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/tsort.rb:182:in `block in each_strongly_connected_component'
  /home/developer/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/tsort.rb:180:in `each'
  /home/developer/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/tsort.rb:180:in `each_strongly_connected_component'
  /home/developer/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/tsort.rb:148:in `tsort_each'
  /home/developer/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/gems/2.0.0/gems/railties-4.0.2/lib/rails/initializable.rb:54:in `run_initializers'
  /home/developer/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/gems/2.0.0/gems/railties-4.0.2/lib/rails/application.rb:215:in `initialize!'
  /home/developer/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/gems/2.0.0/gems/railties-4.0.2/lib/rails/railtie/configurable.rb:30:in `method_missing'
  /home/developer/finantec/config/environment.rb:5:in `&lt;top (required)&gt;'
  /home/developer/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/gems/2.0.0/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:229:in `require'
  /home/developer/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/gems/2.0.0/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:229:in `block in require'
  /home/developer/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/gems/2.0.0/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:214:in `load_dependency'
  /home/developer/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/gems/2.0.0/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:229:in `require'
  /home/developer/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/gems/2.0.0/gems/railties-4.0.2/lib/rails/application.rb:189:in `require_environment!'
  /home/developer/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/gems/2.0.0/gems/railties-4.0.2/lib/rails/application.rb:250:in `block in run_tasks_blocks'
  /home/developer/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/gems/2.0.0/gems/rake-10.2.2/lib/rake/task.rb:240:in `call'
  /home/developer/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/gems/2.0.0/gems/rake-10.2.2/lib/rake/task.rb:240:in `block in execute'
  /home/developer/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/gems/2.0.0/gems/rake-10.2.2/lib/rake/task.rb:235:in `each'
  /home/developer/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/gems/2.0.0/gems/rake-10.2.2/lib/rake/task.rb:235:in `execute'
  /home/developer/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/gems/2.0.0/gems/rake-10.2.2/lib/rake/task.rb:179:in `block in invoke_with_call_chain'
  /home/developer/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/monitor.rb:211:in `mon_synchronize'
  /home/developer/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/gems/2.0.0/gems/rake-10.2.2/lib/rake/task.rb:172:in `invoke_with_call_chain'
  /home/developer/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/gems/2.0.0/gems/rake-10.2.2/lib/rake/task.rb:201:in `block in invoke_prerequisites'
  /home/developer/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/gems/2.0.0/gems/rake-10.2.2/lib/rake/task.rb:199:in `each'
  /home/developer/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/gems/2.0.0/gems/rake-10.2.2/lib/rake/task.rb:199:in `invoke_prerequisites'
  /home/developer/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/gems/2.0.0/gems/rake-10.2.2/lib/rake/task.rb:178:in `block in invoke_with_call_chain'
  /home/developer/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/monitor.rb:211:in `mon_synchronize'
  /home/developer/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/gems/2.0.0/gems/rake-10.2.2/lib/rake/task.rb:172:in `invoke_with_call_chain'
  /home/developer/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/gems/2.0.0/gems/rake-10.2.2/lib/rake/task.rb:165:in `invoke'
  /home/developer/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/gems/2.0.0/gems/rake-10.2.2/lib/rake/application.rb:150:in `invoke_task'
  /home/developer/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/gems/2.0.0/gems/rake-10.2.2/lib/rake/application.rb:106:in `block (2 levels) in top_level'
  /home/developer/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/gems/2.0.0/gems/rake-10.2.2/lib/rake/application.rb:106:in `each'
  /home/developer/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/gems/2.0.0/gems/rake-10.2.2/lib/rake/application.rb:106:in `block in top_level'
  /home/developer/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/gems/2.0.0/gems/rake-10.2.2/lib/rake/application.rb:115:in `run_with_threads'
  /home/developer/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/gems/2.0.0/gems/rake-10.2.2/lib/rake/application.rb:100:in `top_level'
  /home/developer/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/gems/2.0.0/gems/rake-10.2.2/lib/rake/application.rb:78:in `block in run'
  /home/developer/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/gems/2.0.0/gems/rake-10.2.2/lib/rake/application.rb:176:in `standard_exception_handling'
  /home/developer/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/gems/2.0.0/gems/rake-10.2.2/lib/rake/application.rb:75:in `run'
  /home/developer/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/gems/2.0.0/gems/rake-10.2.2/bin/rake:33:in `&lt;top (required)&gt;'
  /home/developer/.rvm/gems/ruby-2.0.0-p247@global/bin/rake:23:in `load'
  /home/developer/.rvm/gems/ruby-2.0.0-p247@global/bin/rake:23:in `&lt;main&gt;'
  /home/developer/.rvm/gems/ruby-2.0.0-p247/bin/ruby_executable_hooks:15:in `eval'
  /home/developer/.rvm/gems/ruby-2.0.0-p247/bin/ruby_executable_hooks:15:in `&lt;main&gt;'
  Tasks: TOP =&gt; db:migrate =&gt; environment
  </code></pre>
  
  <p><code>Importer.rb</code>:</p>
  
  <pre><code># require 'active_importer'
  
  module Importr
    class Importer &lt; ActiveImporter::Base
      def initialize(file, options = {})
        # TODO: ensure that data_import.model_class == self.class.model_class
  
        super
  
        if data_import &amp;&amp; data_import.finished
          raise "Data import #{data_import.id} was already processed"
        end
      end
  
      alias_method :data_import, :context
  
      on :row_success do
        update_counters
        notify(:success, @counters)
      end
  
      on :row_error do |e|
        update_counters({index: row_index, error: e.message})
        notify(:error, @counters.merge(index: row_index, error: e.message))
      end
  
      on :import_failed do |e|
        notify(:base, error: e.message)
      end
  
      on :import_finished do
        data_import.update_attribute(:finished, true) if data_import
      end
  
      private
  
      def notify(subchannel, message)
        channel = ["/#{self.class}/#{subchannel}", data_import.try(:uuid)].compact.join("-")
        Importr::Notifier.notify(channel, message)
      end
  
      def update_counters(err= {})
        @counters = {
          success_count: row_success_count,
          error_count: row_error_count,
          processed_rows: row_processed_count,
          total_rows: row_count,
        }
        if data_import
          data_import.update_attributes(@counters) 
          add_error(err) unless err.blank?
        end
      end
  
      def add_error(err)
        data_import.update_attributes(error_messages: data_import.error_messages &lt;&lt; err ) if data_import
      end
    end
  end
  </code></pre>