我关注了IronWorkerNG :: Client.new和rails的所有文档:
https://github.com/iron-io/iron_worker_rails_example
我的.worker文件正在执行:
runtime 'ruby'
name 'CompanyList'
merge_gem 'activerecord'
merge_gem 'actionmailer'
merge_gem 'pg'
merge_gem 'aws-s3'
dir '../app/models'
file '../app/mailers/result_mailer.rb'
file "../app/views/result_mailer/email.html.erb", "result_mailer"
exec 'company_list.rb'
remote
我的ruby文件确实:
require 'action_mailer'
require 'active_record'
require 'aws/s3'
require 'pg'
require 'models/company_list.rb'
require 'result_mailer.rb'
puts "Starting CompanyList worker at #{Time.now}"
ActiveRecord::Base.establish_connection(params['database'])
mailer_config = params['mailer'].inject({}) { |memo, (k, v)| memo[k.to_sym] = v; memo }
#ActionMailer::Base.prepend_view_path('.')
ActionMailer::Base.view_paths = ['.']
ActionMailer::Base.smtp_settings = mailer_config
ActionMailer::Base.delivery_method = :smtp
但每次我收到此错误:
/task/__gems__/gems/actionmailer-2.3.18/lib/action_mailer/base.rb:433:
in `method_missing': undefined method `email' for ResultMailer:Class
(NoMethodError)
from /task/models/company_list.rb:16:in `process_file'
from /task/company_list.rb:18:in `<top (required)>'
from /usr/local/lib/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from /usr/local/lib/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from __runner__.rb:213:in `<main>'
和ResultMailer DOES有一个电子邮件方法:
class ResultMailer < ActionMailer::Base
def email
to = 'andrew@testdomain.com'
mail :from => 'test@testdomain.com', :to => to, :subject => "Test"
end
end
任何想法为什么action_mailer基线433抛出该错误?我可以从我本地系统的控制台上调用ResultMailer.email.deliver就好了。使用heroku和iron.io进行生产时出现此错误。
答案 0 :(得分:4)
啊,有时在stackoverflow上写出问题会让你看到问题。我需要:
merge_gem "activerecord", "=3.2.8"
merge_gem 'actionmailer', '=3.2.8'
没有3.2.8版本,它使用了旧版本的动作邮件程序。