我正在使用Ruby on Rails 3.1和DelayedJob gem。我有一个联系我们表格,人们可以通过该表格与我联系。当我提交时,我收到以下错误
`last_error` = '{Job failed to load: uninitialized constant Syck::Syck. Handler: \"--- !ruby/struct:Delayed::PerformableMailer ...
但是,我还有其他发送电子邮件的表单(例如:注册和登录用户),这些表格按预期工作。 “联系我们”表单似乎发生了唯一的问题。
我读了其他相关问题的帖子,但我仍然无法使其工作...... 我该如何解决问题?
P.S。:在升级到Rails 3.1之前,似乎有效。
更新
现在我的'boot.rb'文件是
require 'rubygems'
require 'yaml'
YAML::ENGINE.yamler= 'syck'
# Set up gems listed in the Gemfile.
gemfile = File.expand_path('../../Gemfile', __FILE__)
begin
ENV['BUNDLE_GEMFILE'] = gemfile
require 'bundler'
Bundler.setup
rescue Bundler::GemNotFound => e
STDERR.puts e.message
STDERR.puts "Try running `bundle install`."
exit!
end if File.exist?(gemfile)
在要求yaml
之后我收到此错误(注意:Syck::Syck::BadAlias
是“新的”\“与之前的”错误不同“:
{Job failed to load: uninitialized constant Syck::Syck::BadAlias. Handler: \"--- !ruby/struct:Delayed::PerformableMailer ...
我的'database.yml'文件是:
development:
adapter: mysql2
encoding: utf8
reconnect: false
database: app_name_development
pool: 5
username: root
password:
socket: /tmp/mysql.sock
test:
adapter: mysql2
encoding: utf8
reconnect: false
database: app_name_test
pool: 5
username: root
password:
socket: /tmp/mysql.sock
production:
adapter: mysql2
encoding: utf8
reconnect: false
database: app_name_production
pool: 5
username: root
password: *******
socket: /var/run/mysqld/mysqld.sock
更新
我的'Gemfile'文件是:
source 'http://rubygems.org'
gem 'rails', '3.1.0'
gem 'rake'
gem 'mysql2'
gem 'paperclip', '~> 2.3'
gem 'will_paginate', '~> 3.0.pre2'
gem 'delayed_job'
gem 'memcache-client', '1.8.5'
group :assets do
gem 'sass-rails', '~> 3.1.0'
gem 'coffee-rails', '~> 3.1.0'
gem 'uglifier'
end
gem 'jquery-rails'
gem 'capistrano'
gem "rdoc", "~> 3.6.1"
group :test do
# Pretty printed test output
gem 'turn', :require => false
end
其他信息
目前,为了调用传递方法,我使用以下代码:
::Pages::Mailer.delay.contact_us(@user) # It doesn't work and doesn't send the e-mail
另一方面,如果我使用以下代码:
# Note: It doesn't have the '::' at the beginning
Pages::Mailer.delay.contact_us(@user) # It doesn't work and raise the 'NameError' (described below)
我收到此错误:
NameError (uninitialized constant ActionController::Caching::Pages::Mailer)
如果我使用“未延迟”版本,也会发生同样的情况:
::Pages::Mailer.contact_us(@user).deliver # It works and SENDS THE E-MAIL!!!
Pages::Mailer.contact_us(@user).deliver # It doesn't work and raise the 'NameError'
答案 0 :(得分:1)
Syck是一个Yaml解析器,所以你的某个Yaml文件中可能有错误? Locale文件或您的database.yml都是不错的选择。
如果失败了,请通过将以下内容添加到boot.rb来确保yaml解析器正在使用正确的yamler:
require 'yaml'
YAML::ENGINE.yamler= 'syck'
答案 1 :(得分:1)