我正在尝试使用Whenever gem 来安排每周发送电子邮件的任务。我首先测试了每次更新用户时都会通过调用方法来发送电子邮件。所以现在,我尝试每周发送电子邮件而不是每次更新,但是我在 cron.log 文件中不断收到以下错误:
Could not find multi_json-1.1.0 in any of the sources (Bundler::GemNotFound)
我已经做了很多研究,还没有发现任何东西,任何帮助都会很棒。我将在下面发布相关代码:
应用程序/mailers/weekly_digest_test_mailer.rb
class WeeklyDigestTestMailer < ActionMailer::Base
default from: "from@example.com"
def send_email(user)
@user = user
@last_question = @user.questions.last.description
mail to: @user.email, subject: "This is a test email"
end
end
应用程序/模型/user.rb
def self.send_email_to_user
WeeklyDigestTestMailer.send_email(self).deliver
end
配置/时间表.rb
every 1.minute do
runner "User.send_email_to_user", :environment => 'development', :output => 'log/cron.log'
end
宝石文件
source 'https://rubygems.org'
gem 'rails', '3.2.0'
gem "bootstrap-tooltip-rails", "~> 0.1"
gem 'whenever', :require => false
group :production do
gem "exception_notification", "~> 2.5.2", :require => 'exception_notifier'
gem "mysql", "~> 2.8.1"
end
group :assets do
gem 'sass-rails', '~> 3.2.3'
gem 'coffee-rails', '~> 3.2.1'
gem 'uglifier', '>= 1.0.3'
end
gem "jquery-rails"
gem "devise", "~> 2.0.4"
gem 'gauge', git: 'git@github.com:AgilionApps/gauges.git'
gem "capistrano"
gem "capistrano-ext"
group :development do
gem "awesome_print", "~> 1.0.2"
gem "mail", "2.4.1"
end
group :test do
gem "minitest", "~> 2.11.2"
gem "turn", "~> 0.9.3"
gem "mocha", "~> 0.10.4"
end
group :test, :development do
gem "sqlite3", "~> 1.3.5"
end
group :staging do
# gem "pg", "~> 0.13.1"
end
捆绑安装输出:
Using rake (0.9.2.2)
Using i18n (0.6.0)
Using multi_json (1.1.0)
Using activesupport (3.2.0)
Using builder (3.0.0)
Using activemodel (3.2.0)
Using erubis (2.7.0)
Using journey (1.0.3)
Using rack (1.4.1)
Using rack-cache (1.1)
Using rack-test (0.6.1)
Using hike (1.2.1)
Using tilt (1.3.3)
Using sprockets (2.1.2)
Using actionpack (3.2.0)
Using mime-types (1.17.2)
Using polyglot (0.3.3)
Using treetop (1.4.10)
Using mail (2.4.1)
Using actionmailer (3.2.0)
Using arel (3.0.2)
Using tzinfo (0.3.31)
Using activerecord (3.2.0)
Using activeresource (3.2.0)
Using ansi (1.4.2)
Using awesome_print (1.0.2)
Using bcrypt-ruby (3.0.1)
Using bundler (1.1.4)
Using rack-ssl (1.3.2)
Using json (1.6.5)
Using rdoc (3.12)
Using thor (0.14.6)
Using railties (3.2.0)
Using rails (3.2.0)
Using bootstrap-tooltip-rails (0.1)
Using highline (1.6.11)
Using net-ssh (2.3.0)
Using net-scp (1.0.4)
Using net-sftp (2.0.5)
Using net-ssh-gateway (1.1.0)
Using capistrano (2.11.2)
Using capistrano-ext (1.2.1)
Using chronic (0.6.7)
Using coffee-script-source (1.2.0)
Using execjs (1.3.0)
Using coffee-script (2.2.0)
Using coffee-rails (3.2.2)
Using orm_adapter (0.0.6)
Using warden (1.1.1)
Using devise (2.0.4)
Using exception_notification (2.5.2)
Using gauge (0.0.2) from git@github.com:AgilionApps/gauges.git (at master)
Using jquery-rails (2.0.0)
Using metaclass (0.0.1)
Using minitest (2.11.2)
Using mocha (0.10.4)
Using mysql (2.8.1)
Using sass (3.1.15)
Using sass-rails (3.2.4)
Using sqlite3 (1.3.5)
Using turn (0.9.3)
Using uglifier (1.2.3)
Using whenever (0.7.3)
Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed.