我正在对我的应用程序进行故障排除,以了解电子邮件通过Rake失败的原因。
我的用户模型:
class User < ActiveRecord::Base
def User.test
puts "a string is returned"
UserMailer.email_test
end
end
我的UserMailer:
class UserMailer < ActionMailer::Base
def email_test
mail to: "test", subject: "test"
e
我已经为Mailer创建了一个Rake,稍后将其计划为wth,并在向用户发送电子邮件时使用Gem自动执行任务。一段时间内,这只是一个测试,以确定任务是否有效。
我的Rake和Mailer如下。
require 'rake'
desc 'send digest email'
task send_warn_course: :environment do
MailCourseWarnMailer.course_available(user).deliver!
end
# And my Mailer is:
class MailCourseWarnMailer
我有以下任务:
namespace :db do
desc "Drop, create, migrate, seed the database and prepare the test database for rspec"
task :reset_db => :environment do
puts "Environment Check: Rails Environment = #{Rails.env}"
Rake::Task['db:drop'].invoke
Rake::Task['db:cre
我正尝试在Rails 4应用程序中创建两个自定义rake任务。他们应该读取agent_card表,并根据逻辑,在触发时间时发出一封电子邮件。这是我第一次创建rake任务,我没有收到错误,因此我不知道我是否做得正确。我会假设在使用邮件时,一旦邮件被解雇,开信器就会工作(应该都正常工作),但我不确定。我已经在下面发布了所有相关的代码。提前感谢!
.rake文件
namespace :agent_cards do
desc 'Sends an email to an agent with a license expiring 2 months from today'
ta
如果lib/任务如下所示,则使用Rails 2.3.10
lib/tasks
- a.rake
- b.rake
a.rake看起来是这样的:
namespace :a do
desc "Task A"
task(:a=>:environment)do
msg('I AM TASK A')
end
def msg(msg)
puts "MSG SENT FROM Task A: #{msg}"
end
end
b.rake看起来像这样
namespace :b do
我有一个rake任务,每天发送一天玩家活动的电子邮件。(请参阅下面的示例代码。)如果我在我的控制台中运行PlayerActivityMailer.activity_report.deliver,一切都会正常工作。但是,当我试图调用rake任务时,我会得到以下错误:
rake aborted!
ActionView::Template::Error: arguments passed to url_for can't be handled.
Please require routes or provide your own implementation
在做了一些研究之后,我发现在Rai
我有一个Rails2.2项目,我想在其中覆盖rake db:test:prepare任务的功能。我以为这能行得通,但它不是:
#lib/tasks/db.rake
namespace :db do
namespace :test do
desc "Overridden version of rails' standard db:test:prepare task since the schema dump used in that can't handle DB enums"
task :prepare => [:environme
我搞不懂,我有这门课
class UserMailer < ActionMailer::Base
def apps_remainder_email()
#apps array ..which basically have 3 records in it
apps.each do |rec||
mail(to: user.email, subject: 'Apps Remainder').deliver
end
end
end
当我试图在rails控制台UserMailer.apps_remainder_email中调用上面的内容时,它
是什么原因导致Rails每次运行迁移?
我正在部署到qa环境中,每次都运行迁移,就好像rails再次设置整个数据库一样。
这是我的config/environments/qa.rb
Backend::Application.configure do
# Settings specified here will take precedence over those in config/application.rb
config.assets.compile = true
config.serve_static_assets = false
# In the developme
我为在亚马逊EC2上测试CRON作业准备了一个简单的任务:
schedule.rb
set :output, "/home/a/b/current/log/cron_log.log"
every 5.minutes do
#command "/usr/bin/some_great_command"
#runner "MyModel.some_method"
#rake "some:great:rake:task"
puts "It's working !!!"
runner
在我要从Rails 3.2.22.4升级到Rails 4.0.13的应用程序上,以下用于增强全局环境任务的代码块由于不能在目标Rails版本上运行而成为障碍:
Rails.application.class.rake_tasks do
Rake::Task["environment"].enhance do
...
我已经成功地在heroku cedar堆栈上运行resque,并将接口挂载到rails上。
当我启动worker时,一切工作正常。工人处理作业。但当我杀了工人,Resque仍然认为工人是可用的。当我启动另一个worker时,它会认为有2个worker,但实际上只有一个在运行。
我还注意到在这里的表单中,heroku在杀死一个工人时发送SIGTERM,如果没有终止,那么它发送SIGKILL。
这是我的工作日志
2011-08-11T02:32:45+00:00 heroku[worker.1]: Starting process with command `bundle exec rake re
在一个新的rails项目中,Rakefile看起来像这样:
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
require File.expand_path('../config/application', __FILE__)
Blog::Application.load_tasks
然而,rake route
当我去heroku run rake的时候,Rake被取消了,下一行说,Don't know how to build task 'default'
Ran heroku run rake --trace和got
Running `rake --trace` attached to terminal... up, run.3479
DEPRECATION WARNING: You have Rails 2.3-style plugins in vendor/plugins! Support for these plugins will be removed in
Cron作业不能在Rails3中工作,只要gem是我正在使用的代码,我就会使用。
schedule.rb文件
every 1.hours do
command "cd /home/me/my_app/current"
rake "thinking_sphinx:index RAILS_ENV=production"
end
every 1.day, :at => '12.01 am' do
command "cd /home/me/my_app/current"
rake "messag
我是Rails的新手,所以请原谅我对Rails缺乏理解。我已经通过RubyGems安装了最新版本的RubyGems、Ruby、Rails、Rake和MySQL等,但是当我开始开发一个基本的Rails应用时,我遇到了这个问题:
Icarus:temporary atg$ rails new people
... (output omitted) ...
Icarus:temporary atg$ cd people
Icarus:people atg$ rake db:create
(in /Users/atg/temporary/people)
rake aborted!
uninit
我正在用Rails (3)应用程序建立第二个数据库,所以我想创建一个rake任务来创建第二个开发数据库。我试图覆盖rake db:create任务,以便它完成我需要的所有数据库创建。然而,我似乎找不到合适的方法来完成这个任务。我尝试了几种方法--从URL建立到数据库的连接:
# remove db:create from the list of rake tasks in order to override it
db_create = Rake.application.instance_variable_get('@tasks').delete('db:create&
我有一个rake任务,它应该每天发送邮件给用户,使他们的每日字段==为真。(我已经在我的项目中有一个正在工作的邮件实现,它在创建帐户和重置密码时发送邮件)。我正在使用
问题是,由于我不在生产环境中,我不知道如何测试它是否工作。
这是我的UserMailer:
def daily_mail(user)
@user = user
mail to: user.email, subject: "Mail journalier"
end
我的rake任务:
desc“向用户发送电子邮件”
task :email_sender => :environment do |