我使用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之前,它似乎起了作用。
@Shaun的更新
现在我的“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@KensoDev的更新
我的“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'发布于 2011-09-21 10:03:35
我写了一篇关于它的文章。
http://www.kensodev.com/2011/08/16/uninitialized-constant-sycksyck-nameerror/
发布于 2011-09-21 09:16:17
Syck是一个Yaml解析器,所以您可能在其中一个Yaml文件中出错了?地区文件或您的database.yml是很好的选择。
如果失败,请确保yaml解析器使用的是正确的yamler,方法是向boot.rb添加以下内容:
require 'yaml'
YAML::ENGINE.yamler= 'syck'https://stackoverflow.com/questions/7496779
复制相似问题