我有一个由第三方服务调用的rake任务。在我的应用程序中,我需要在启动应用程序之前设置Customer。我无法从rake任务访问模型变量。但这只发生在生产而非发展中。我跑的时候
RAILS_ENV = 'production' rake auth:tester
我收到了以下错误。
rake aborted!
Unable to autoload constant CUSTOMER, expected /home/suganya/academics/tsg-mcds-server/app/models/customer.rb to define it
/home/suganya/.rvm/gems/ruby-2.0.0-p353/gems/activesupport-4.2.7.1/lib/active_support/dependencies.rb:495:in `load_missing_constant'
/home/suganya/.rvm/gems/ruby-2.0.0-p353/gems/activesupport-4.2.7.1/lib/active_support/dependencies.rb:184:in `const_missing'
/home/suganya/academics/tsg-mcds-server/config/initializers/customer_config.rb:11:in `xml'
/home/suganya/academics/tsg-mcds-server/config/initializers/customer_config.rb:38:in `set_customer_settings'
/home/suganya/academics/tsg-mcds-server/config/initializers/customer_config.rb:710:in `<top (required)>'
/home/suganya/.rvm/gems/ruby-2.0.0-p353/gems/activesupport-4.2.7.1/lib/active_support/dependencies.rb:268:in `load'
/home/suganya/.rvm/gems/ruby-2.0.0-p353/gems/activesupport-4.2.7.1/lib/active_support/dependencies.rb:268:in `block in load'
/home/suganya/.rvm/gems/ruby-2.0.0-p353/gems/activesupport-4.2.7.1/lib/active_support/dependencies.rb:240:in `load_dependency'
/home/suganya/.rvm/gems/ruby-2.0.0-p353/gems/activesupport-4.2.7.1/lib/active_support/dependencies.rb:268:in `load'
/home/suganya/.rvm/gems/ruby-2.0.0-p353/gems/railties-4.2.7.1/lib/rails/engine.rb:652:in `block in load_config_initializer'
我已提到所有相关问题。当我启用poduction.rb
时config.threadsafe!
config.dependency_loading = true if $rails_rake_task
我收到以下错误。
undefined method `threadsafe!' for #<Rails::Application::Configuration:0x00000004aebdf8>
我也试过
Rails.application.eager_load!
这是我的佣金任务:
namespace :authentication do
desc "Automatically runs authentication tester"
task :tester => :environment do
Rake.application.rake_require "#{Rails.root}/config/initialize_customer_in_development.rb"
begin
AuthenticationTester.perform
rescue
SystemEvent.error(50049, "Authentication Tester Finished Unsuccessfully.")
end
end
端
没有任何帮助。请帮忙解决这个问题。