1

I am using Ruby on Rails 3.1 and the DelayedJob gem. I have a Contact Us form through which people can contact me. When I submit that I get the following error

`last_error` = '{Job failed to load: uninitialized constant Syck::Syck. Handler: \"--- !ruby/struct:Delayed::PerformableMailer ...

However, I have also others forms that send e-mails (eg: Sign Up and Sign In users) and those work as expected. The only problem seems to occur with the Contact Us form.

I read others related problem posts but I still cannot make that to work... how can I solve the problem?

P.S.: It seems that before upgrading to Rails 3.1 it worked.


UPDATE for @Shaun

Now my 'boot.rb' file is

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)

After requiring yaml I get this error (note: Syck::Syck::BadAlias is "a new"\"different from the previous" error):

{Job failed to load: uninitialized constant Syck::Syck::BadAlias. Handler: \"--- !ruby/struct:Delayed::PerformableMailer ...

My 'database.yml' file is:

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

UPDATE for @KensoDev

My 'Gemfile' file is:

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

ADDITIONAL INFORMATION

At this time, in order to call the delivering method, I use the following code:

::Pages::Mailer.delay.contact_us(@user)   # It doesn't work and doesn't send the e-mail

On the other hand, if I use the following code:

# 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)

I get this error:

NameError (uninitialized constant ActionController::Caching::Pages::Mailer)

The same happens if I use the "not delayed" version:

::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'
user12882
  • 4,702
  • 9
  • 39
  • 54

2 Answers2

1

Syck is a Yaml parser, so maybe you have an error in one of your Yaml files? Locale files or your database.yml are good bets.

Failing that, make sure that the yaml parser is using the correct yamler by adding the following to boot.rb:

require 'yaml'
YAML::ENGINE.yamler= 'syck'
Shaun
  • 549
  • 3
  • 10
  • Your question is the same as this: http://stackoverflow.com/questions/5179696/job-failed-to-load-uninitialized-constant-sycksyck and that solution seems do not work for me. Just to be sure I also updated the question with the content of my 'boot.rb' file and a related question. *BTW*: how can I check if I have an error in some of my Yaml files? If I am not wrong I have just the database.yml file. – user12882 Sep 21 '11 at 09:49
  • It's the only solution I've ever had to use for Syck/Yaml related issues. To answer your questions, I include the YAML::Engine directly below "require rubygems". As for your database.yml file, could you paste in its contents? Masking all sensitive data, of course. – Shaun Sep 21 '11 at 09:54
  • That said, if your database.yml file is indented consistently, and doesn't use any special characters, it's probably fine. – Shaun Sep 21 '11 at 09:55
  • Did you restart your server, and also all running delayed jobs? It may be advisable to clear your jobs table as well, and try it from a clean slate (the environment is stored in the job). – Shaun Sep 21 '11 at 10:22
  • Now (I restart the server and also all running delayed jobs - more I rebooted the database) I get the DelayedJob `last_error = '{undefined method confirm_authentication ...` error related to the Sign Up process for sending e-mail. – user12882 Sep 21 '11 at 10:41
  • If I do *not* add the `require 'yaml'; YAML::ENGINE.yamler= 'syck'` code in the `boot.rb` file I get in the logger file the same error as described in the question, but in the console I get: `1 jobs processed at 151.3370 j/s, 0 failed ...`! *What that means* (since I have `0 failed` jobs) *?!* – user12882 Sep 21 '11 at 10:57
  • `undefined method confirm_authentication ...` doesn't seem to be related to syck or anything mentioned so far, so I'm not quite sure what you mean by that. As for the console/log difference, I'm afraid I don't know what that means. Possibly the job finished but threw an error logging that fact? No idea why that would happen though – Shaun Sep 21 '11 at 11:07
  • I discovered what generates the problem http://stackoverflow.com/questions/7507697/delayedjob-how-to-solve-the-problem-job-failed-to-load but I still must solve that. – user12882 Sep 21 '11 at 22:56
1

I wrote a post about it.

http://www.kensodev.com/2011/08/16/uninitialized-constant-sycksyck-nameerror/

KensoDev
  • 3,285
  • 21
  • 38
  • I had some problem by running the command `gem update --system`: http://stackoverflow.com/questions/7496519/trouble-on-re-installing-ruby-from-scratch... What should I do?(!) – user12882 Sep 21 '11 at 10:16
  • Despite my previous (negative) experience I have tried to run the `gem update --system` command and I get the following message: `Latest version currently installed. Aborting.`. – user12882 Sep 21 '11 at 10:50
  • Yes, I am. *BTW*: In the logger file I get the same error as described in the question but at the same time in the console I get `1 jobs processed at 151.3370 j/s, 0 failed` (note: *0 failed*). – user12882 Sep 21 '11 at 11:25
  • is your rvm running the same version of rubygems like your system? – KensoDev Sep 21 '11 at 11:26
  • what version of Ruby are you running? – KensoDev Sep 21 '11 at 11:27
  • `$ which ruby # => /Users//.rvm/rubies/ruby-1.9.2-p290/bin/ruby` – user12882 Sep 21 '11 at 11:28
  • Maybe the problem is related to `rake` and `mysql2`. Before I upgraded to Rails 3.1 those was stated in this way: `rake, '0.8.7'` `mysql2, '< 0.3'` but doing that I was getting the following warning message: `$ rake jobs:work # => rake aborted! You have already activated rake 0.9.2, but your Gemfile requires rake 0.8.7. Consider using bundle exec.` – user12882 Sep 21 '11 at 11:47
  • I discovered what generates the problem http://stackoverflow.com/questions/7507697/delayedjob-how-to-solve-the-problem-job-failed-to-load but I still must solve that. – user12882 Sep 21 '11 at 22:56