Обновление до Rails 3.2.2: как устранить ошибку «неопределенный метод для Syck :: DomainType», связанную с гемом Delayed Job? - PullRequest
3 голосов
/ 13 марта 2012

Я использую Ruby on Rails 3.2.2 из 3.1.0.У меня есть проблема

undefined method send_register_email\' for #<Syck::DomainType:0x0000012d2346b8>\n/<ABSOLUTE_PATH>/.rvm/gems/ruby-1.9.2-p290/gems/delayed_job-3.0.1/lib/delayed/performable_mailer.rb:6:in perform ...

с драгоценным камнем DelayedJob, которую пытались решить многие другие: кто-то успешно это сделал, кто-то нет.Я нахожусь в последней категории, также, если я попробовал все решения, которые я нашел в Интернете.

В настоящее время в моем Gemfile у меня есть:

gem 'rails', '3.2.2'
gem "rake"
...
gem 'delayed_job_active_record'
...

Перед обновлением Rails,в моем Gemfile у меня было:

gem 'rails', '~> 3.1.0'
gem "rake"
...
# I also used the following statement by running Rails 3.2.2 but it didn't work.
gem 'delayed_job'
...

Чтобы отправлять сообщения электронной почты, в моих контроллерах я использую следующую кодовую ссылку:

::Users::Mailer.delay.send_register_email(@user)

В моем APPLICATION_ROOT/app/mailers/users/mailer.rb файле Ihave:

class Users::Mailer < ActionMailer::Base
  ...

  def send_register_email(user)
    ...
  end
end

До обновления до Rails 3.2.2 все работало также.Теперь я получаю ошибку, упомянутую выше, во вводном тексте. Как я могу решить проблему с отложенным заданием?


Я заметил, что в таблице базы данных, связанной с гемом delayed_job_active_record, должен быть столбец с именем «очередь» (см.раздел «Gory Details» в официальной документации для получения дополнительной информации).Однако, поскольку я использовал gem 'delayed_job', он присутствовал в этой таблице базы данных. Может быть, в этом проблема?


Еще одна вещь, которую я заметил, - это следующее (но я думаю, что это не проблема, пока):

$ rake jobs:work
DEPRECATION WARNING: You have Rails 2.3-style plugins in vendor/plugins! Support for these plugins will be removed in Rails 4.0. Move them out and bundle them in your Gemfile, or fold them in to your app as lib/myplugin/* and config/initializers/myplugin.rb. See the release notes for more on this: http://weblog.rubyonrails.org/2012/01/04/rails-3-2-0-rc2-has-been-released. (called from <top (required)> at /<ABSOLUTE_PATH>/Rakefile:7)
DEPRECATION WARNING: You have Rails 2.3-style plugins in vendor/plugins! Support for these plugins will be removed in Rails 4.0. Move them out and bundle them in your Gemfile, or fold them in to your app as lib/myplugin/* and config/initializers/myplugin.rb. See the release notes for more on this: http://weblog.rubyonrails.org/2012/01/04/rails-3-2-0-rc2-has-been-released. (called from <top (required)> at /<ABSOLUTE_PATH>/Rakefile:7)
[Worker(host:<MY_USER>.local pid:76826)] Starting job worker



Ниже приведено описание столбца таблицы базы данных DelayedJob last_error:

{undefined method `send_register_email' for #<Syck::DomainType:0x0000010228a840>
/<ABSOLUTE_PATH>/.rvm/gems/ruby-1.9.2-p290/gems/delayed_job-3.0.1/lib/delayed/performable_mailer.rb:6:in `perform'
/<ABSOLUTE_PATH>/.rvm/gems/ruby-1.9.2-p290/gems/delayed_job-3.0.1/lib/delayed/backend/base.rb:94:in `block in invoke_job'
/<ABSOLUTE_PATH>/.rvm/gems/ruby-1.9.2-p290/gems/delayed_job-3.0.1/lib/delayed/lifecycle.rb:60:in `call'
/<ABSOLUTE_PATH>/.rvm/gems/ruby-1.9.2-p290/gems/delayed_job-3.0.1/lib/delayed/lifecycle.rb:60:in `block in initialize'
/<ABSOLUTE_PATH>/.rvm/gems/ruby-1.9.2-p290/gems/delayed_job-3.0.1/lib/delayed/lifecycle.rb:65:in `call'
/<ABSOLUTE_PATH>/.rvm/gems/ruby-1.9.2-p290/gems/delayed_job-3.0.1/lib/delayed/lifecycle.rb:65:in `execute'
/<ABSOLUTE_PATH>/.rvm/gems/ruby-1.9.2-p290/gems/delayed_job-3.0.1/lib/delayed/lifecycle.rb:38:in `run_callbacks'
/<ABSOLUTE_PATH>/.rvm/gems/ruby-1.9.2-p290/gems/delayed_job-3.0.1/lib/delayed/backend/base.rb:91:in `invoke_job'
/<ABSOLUTE_PATH>/.rvm/gems/ruby-1.9.2-p290/gems/delayed_job-3.0.1/lib/delayed/worker.rb:162:in `block (2 levels) in run'
/<ABSOLUTE_PATH>/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/timeout.rb:58:in `timeout'
/<ABSOLUTE_PATH>//.rvm/gems/ruby-1.9.2-p290/gems/delayed_job-3.0.1/lib/delayed/worker.rb:162:in `block in run'
/<ABSOLUTE_PATH>//.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/benchmark.rb:310:in `realtime'
/<ABSOLUTE_PATH>//.rvm/gems/ruby-1.9.2-p290/gems/delayed_job-3.0.1/lib/delayed/worker.rb:161:in `run'
/<ABSOLUTE_PATH>//.rvm/gems/ruby-1.9.2-p290/gems/delayed_job-3.0.1/lib/delayed/worker.rb:218:in `block in reserve_and_run_one_job'
/<ABSOLUTE_PATH>//.rvm/gems/ruby-1.9.2-p290/gems/delayed_job-3.0.1/lib/delayed/lifecycle.rb:60:in `call'
/<ABSOLUTE_PATH>//.rvm/gems/ruby-1.9.2-p290/gems/delayed_job-3.0.1/lib/delayed/lifecycle.rb:60:in `block in initialize'
/<ABSOLUTE_PATH>//.rvm/gems/ruby-1.9.2-p290/gems/delayed_job-3.0.1/lib/delayed/lifecycle.rb:65:in `call'
/<ABSOLUTE_PATH>//.rvm/gems/ruby-1.9.2-p290/gems/delayed_job-3.0.1/lib/delayed/lifecycle.rb:65:in `execute'
/<ABSOLUTE_PATH>//.rvm/gems/ruby-1.9.2-p290/gems/delayed_job-3.0.1/lib/delayed/lifecycle.rb:38:in `run_callbacks'
/<ABSOLUTE_PATH>//.rvm/gems/ruby-1.9.2-p290/gems/delayed_job-3.0.1/lib/delayed/worker.rb:218:in `reserve_and_run_one_job'
/<ABSOLUTE_PATH>//.rvm/gems/ruby-1.9.2-p290/gems/delayed_job-3.0.1/lib/delayed/worker.rb:146:in `block in work_off'
/<ABSOLUTE_PATH>//.rvm/gems/ruby-1.9.2-p290/gems/delayed_job-3.0.1/lib/delayed/worker.rb:145:in `times'
/<ABSOLUTE_PATH>//.rvm/gems/ruby-1.9.2-p290/gems/delayed_job-3.0.1/lib/delayed/worker.rb:145:in `work_off'
/<ABSOLUTE_PATH>//.rvm/gems/ruby-1.9.2-p290/gems/delayed_job-3.0.1/lib/delayed/worker.rb:117:in `block (4 levels) in start'
/<ABSOLUTE_PATH>//.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/benchmark.rb:310:in `realtime'
/<ABSOLUTE_PATH>//.rvm/gems/ruby-1.9.2-p290/gems/delayed_job-3.0.1/lib/delayed/worker.rb:116:in `block (3 levels) in start'
/<ABSOLUTE_PATH>//.rvm/gems/ruby-1.9.2-p290/gems/delayed_job-3.0.1/lib/delayed/lifecycle.rb:60:in `call'
/<ABSOLUTE_PATH>//.rvm/gems/ruby-1.9.2-p290/gems/delayed_job-3.0.1/lib/delayed/lifecycle.rb:60:in `block in initialize'
/<ABSOLUTE_PATH>//.rvm/gems/ruby-1.9.2-p290/gems/delayed_job-3.0.1/lib/delayed/lifecycle.rb:65:in `call'
/<ABSOLUTE_PATH>//.rvm/gems/ruby-1.9.2-p290/gems/delayed_job-3.0.1/lib/delayed/lifecycle.rb:65:in `execute'
/<ABSOLUTE_PATH>//.rvm/gems/ruby-1.9.2-p290/gems/delayed_job-3.0.1/lib/delayed/lifecycle.rb:38:in `run_callbacks'
/<ABSOLUTE_PATH>//.rvm/gems/ruby-1.9.2-p290/gems/delayed_job-3.0.1/lib/delayed/worker.rb:113:in `block (2 levels) in start'
/<ABSOLUTE_PATH>//.rvm/gems/ruby-1.9.2-p290/gems/delayed_job-3.0.1/lib/delayed/worker.rb:112:in `loop'
/<ABSOLUTE_PATH>//.rvm/gems/ruby-1.9.2-p290/gems/delayed_job-3.0.1/lib/delayed/worker.rb:112:in `block in start'
/<ABSOLUTE_PATH>//.rvm/gems/ruby-1.9.2-p290/gems/delayed_job-3.0.1/lib/delayed/plugins/clear_locks.rb:7:in `call'
/<ABSOLUTE_PATH>//.rvm/gems/ruby-1.9.2-p290/gems/delayed_job-3.0.1/lib/delayed/plugins/clear_locks.rb:7:in `block (2 levels) in <class:ClearLocks>'
/<ABSOLUTE_PATH>//.rvm/gems/ruby-1.9.2-p290/gems/delayed_job-3.0.1/lib/delayed/lifecycle.rb:78:in `call'
/<ABSOLUTE_PATH>//.rvm/gems/ruby-1.9.2-p290/gems/delayed_job-3.0.1/lib/delayed/lifecycle.rb:78:in `block (2 levels) in add'
/<ABSOLUTE_PATH>//.rvm/gems/ruby-1.9.2-p290/gems/delayed_job-3.0.1/lib/delayed/lifecycle.rb:60:in `call'
/<ABSOLUTE_PATH>//.rvm/gems/ruby-1.9.2-p290/gems/delayed_job-3.0.1/lib/delayed/lifecycle.rb:60:in `block in initialize'
/<ABSOLUTE_PATH>//.rvm/gems/ruby-1.9.2-p290/gems/delayed_job-3.0.1/lib/delayed/lifecycle.rb:78:in `call'
/<ABSOLUTE_PATH>//.rvm/gems/ruby-1.9.2-p290/gems/delayed_job-3.0.1/lib/delayed/lifecycle.rb:78:in `block in add'
/<ABSOLUTE_PATH>//.rvm/gems/ruby-1.9.2-p290/gems/delayed_job-3.0.1/lib/delayed/lifecycle.rb:65:in `call'
/<ABSOLUTE_PATH>//.rvm/gems/ruby-1.9.2-p290/gems/delayed_job-3.0.1/lib/delayed/lifecycle.rb:65:in `execute'
/<ABSOLUTE_PATH>//.rvm/gems/ruby-1.9.2-p290/gems/delayed_job-3.0.1/lib/delayed/lifecycle.rb:38:in `run_callbacks'
/<ABSOLUTE_PATH>//.rvm/gems/ruby-1.9.2-p290/gems/delayed_job-3.0.1/lib/delayed/worker.rb:111:in `start'
/<ABSOLUTE_PATH>//.rvm/gems/ruby-1.9.2-p290/gems/delayed_job-3.0.1/lib/delayed/tasks.rb:9:in `block (2 levels) in <top (required)>'
/<ABSOLUTE_PATH>//.rvm/gems/ruby-1.9.2-p290@global/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `call'
/<ABSOLUTE_PATH>//.rvm/gems/ruby-1.9.2-p290@global/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `block in execute'
/<ABSOLUTE_PATH>//.rvm/gems/ruby-1.9.2-p290@global/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `each'
/<ABSOLUTE_PATH>//.rvm/gems/ruby-1.9.2-p290@global/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `execute'
/<ABSOLUTE_PATH>//.rvm/gems/ruby-1.9.2-p290@global/gems/rake-0.9.2.2/lib/rake/task.rb:158:in `block in invoke_with_call_chain'
/<ABSOLUTE_PATH>//.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/monitor.rb:201:in `mon_synchronize'
/<ABSOLUTE_PATH>//.rvm/gems/ruby-1.9.2-p290@global/gems/rake-0.9.2.2/lib/rake/task.rb:151:in `invoke_with_call_chain'
/<ABSOLUTE_PATH>//.rvm/gems/ruby-1.9.2-p290@global/gems/rake-0.9.2.2/lib/rake/task.rb:144:in `invoke'
/<ABSOLUTE_PATH>//.rvm/gems/ruby-1.9.2-p290@global/gems/rake-0.9.2.2/lib/rake/application.rb:116:in `invoke_task'
/<ABSOLUTE_PATH>//.rvm/gems/ruby-1.9.2-p290@global/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `block (2 levels) in top_level'
/<ABSOLUTE_PATH>//.rvm/gems/ruby-1.9.2-p290@global/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `each'
/<ABSOLUTE_PATH>//.rvm/gems/ruby-1.9.2-p290@global/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `block in top_level'
/<ABSOLUTE_PATH>//.rvm/gems/ruby-1.9.2-p290@global/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/<ABSOLUTE_PATH>//.rvm/gems/ruby-1.9.2-p290@global/gems/rake-0.9.2.2/lib/rake/application.rb:88:in `top_level'
/<ABSOLUTE_PATH>//.rvm/gems/ruby-1.9.2-p290@global/gems/rake-0.9.2.2/lib/rake/application.rb:66:in `block in run'
/<ABSOLUTE_PATH>//.rvm/gems/ruby-1.9.2-p290@global/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/<ABSOLUTE_PATH>//.rvm/gems/ruby-1.9.2-p290@global/gems/rake-0.9.2.2/lib/rake/application.rb:63:in `run'
/<ABSOLUTE_PATH>//.rvm/gems/ruby-1.9.2-p290@global/gems/rake-0.9.2.2/bin/rake:33:in `<top (required)>'
/<ABSOLUTE_PATH>//.rvm/gems/ruby-1.9.2-p290/bin/rake:19:in `load'
/<ABSOLUTE_PATH>//.rvm/gems/ruby-1.9.2-p290/bin/rake:19:in `<main>'

Ответы [ 2 ]

6 голосов
/ 04 апреля 2012

Если вы используете bundler, попробуйте добавить префикс сценария или задачи rake к «bundle exec», например:

bundle exec script/delayed_job -n 2 start 

Это помогло нам.

2 голосов
/ 13 марта 2012

Нам удалось устранить странность Syck / Psych в нашем приложении, убедившись, что установка синтаксического анализатора YAML в Syck была абсолютной первой вещью, которая была сделана при инициализации. Причина, по которой вы иногда можете столкнуться с проблемами, заключается в том, что DelayedJob инициализируется по-разному, в зависимости от того, какой анализатор YAML вы используете, и если анализатор изменится во время инициализации, DelayedJob, вероятно, ошибется.

Добавьте это в самый верх boot.rb и посмотрите, поможет ли это:

require 'yaml'
YAML::ENGINE.yamler = 'syck'
...