我在lib/models/alert_import'中有一个文件alert_import,我想在我的任务中使用......这样:
task :send_automate_alerts => :environment do
# STDERR.puts "Path is #{$:}"
Rake.application.rake_require '../../lib/models/alert_import'
ai = AlertImport::Alert.new(2)
ai.send_email_with_notifcations
end
Run Code Online (Sandbox Code Playgroud)
在这段代码中我得到错误:
找不到../../lib/models/alert_import
在AlertImport我有:
module AlertImport
class Alert
def initialize(number_days)
@number_days = number_days
end
def get_all_alerts
alerts = { }
Organization.automate_import.each do |o|
last_import = o.import_histories.where(import_type: "automate").last
last_successful_import = ImportHistory.last_automate_successful_import(o)
if last_import
if last_import.created_at + @number_days.days >= Time.now
alerts[o.id] ="Error during last automate import Last successful import was #{ last_successful_import ? last_successful_import.created_at : "never"}" if last_import.status == "failure"
alerts[o.id] ="Error during last automate …Run Code Online (Sandbox Code Playgroud) 你怎么杀死所有的heroku工人?
我试过了:
heroku scale worker=0
它不起作用.
我想将 activeadmin 过滤器与 hstore 一起使用:
在模型中,我有房间的柱设施。
我想做这样的事情:
过滤器 :amenities, :as => :select, :collection => proc {Room.all.map{|r| r.便利设施} }