我正在努力让我的计算机上的朋友的铁轨项目上的工作成为红宝石。我目前在ubuntu 12.04工作。
设置完所有内容后,我收到了一个我无法在任何地方找到的错误。这是错误消息和importer.rb
文件。
任何帮助都会很棒。
错误消息
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 `<class:Importer>'
/home/developer/finantec/vendor/engines/importr/lib/importr/importer.rb:4:in `<module:Importr>'
/home/developer/finantec/vendor/engines/importr/lib/importr/importer.rb:3:in `<top (required)>'
/home/developer/finantec/app/importers/financial_institution_importer.rb:1:in `<top (required)>'
/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 <top (required)>'
/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 `<top (required)>'
/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 <top (required)>'
/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 `<top (required)>'
/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 <module:Finisher>'
/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 `<top (required)>'
/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 `<top (required)>'
/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 `<main>'
/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 `<main>'
Tasks: TOP => db:migrate => environment
Importer.rb
:
# require 'active_importer'
module Importr
class Importer < ActiveImporter::Base
def initialize(file, options = {})
# TODO: ensure that data_import.model_class == self.class.model_class
super
if data_import && 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 << err ) if data_import
end
end
end
答案 0 :(得分:1)
错误
NameError: undefined method context' for class Importr::Importer'
在线
alias_method :data_import, :context
表示
您正在尝试为名为alias
的方法创建context
,该方法不存在。
在对其进行别名处理之前,请确保您的class Importr::Importer
或其祖先具有名为context
的方法。
答案 1 :(得分:0)
根据this,您应该尝试使用alias_attribute
。该错误可能与天气有关,或者在第一次调用时,您的#context
方法存在于该类中,以及Rails如何使用#method_missing
答案 2 :(得分:0)
我找到了解决方案。
我使用的是最近更新的gem,他们更改了方法的名称。
感谢大家的帮助