.worker 文件
runtime "ruby"
name "UserMailer"
merge_gem "activerecord", "=3.2.8"
merge_gem 'actionmailer', '=3.2.8'
merge_gem 'devise', '=2.1.2'
merge_gem 'pg', "=0.14.0"
merge_file "../app/views/user_mailer/new_user.html.erb" , "user_mailer"
merge_file "../app/mailers/user_mailer.rb"
merge_dir "../app/models"
merge_exec "user_mailer_worker.rb"
.rb 文件
require 'action_mailer'
require 'active_record'
require 'pg'
require 'bcrypt'
require 'devise'
require 'user_mailer.rb'
require 'models/user.rb'
def init_mailer
#Need to convert to proper hashes
mailer_config = params['mailer'].inject({}) { |memo, (k, v)| memo[k.to_sym] = v; memo }
# set default views dir to current dir
ActionMailer::Base.prepend_view_path('.')
ActionMailer::Base.smtp_settings = mailer_config
ActionMailer::Base.delivery_method = :smtp
end
def setup_database
puts "Database connection details:#{params['database'].inspect}"
return unless params['database']
# estabilsh database connection
ActiveRecord::Base.establish_connection(params['database'])
end
init_mailer
setup_database
puts "I got '#{params.inspect}' parameters"
#send email!
# you could use here any active_record queries with models
UserMailer.new_user(User.find(params[:id])).deliver!
我已将代码上传给铁工,但我得到了以下输出
Skipping ruby gem with name='pg' and version='0.14.0' as it contains native extensions, switching to full remote build should fix this
在我在 Iron.io 上排队任务后,我得到了错误
/usr/local/lib/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require': cannot load such file -- pg (LoadError)
from /usr/local/lib/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from /task/user_mailer_worker.rb:4: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:190:in `<main>'
如何在 Iron.io 上要求“pg”宝石?