은 내가 lib 디렉토리/작업/reminder_emails.rake에서 다음 레이크 작업은 한 :레이크 작업 실패 : 환경이로드되지
namespace :tasks do
task :send_reminder_emails => :environment do
Registration.send_reminder_emails
end
end
내가 오류를 설정 bundle exec rake tasks:send_reminder_emails
을 실행 ...
레이크 중단! /home/user/railsApps/nso/app/models/registration.rb에서 등록을 정의하십시오.
레일 콘솔에서 Registration.send_reminder_emails
을 실행할 수 있으며 정상적으로 작동합니다. 내 환경이로드되지 않은 것 같습니다. 그러나, 내가 알기로는 : 환경이 갈퀴 작업에서하는 것.
아이디어가 있으십니까?
편집 : 응용 프로그램/모델/registration.rb
class Registration < ActiveRecord::Base
belongs_to :orientation
attr_accessible :first_name, :last_name, :email, :student_id, :phone, :orientation_id, :checked_in
validates_presence_of :first_name
validates_presence_of :last_name
validates_presence_of :phone
validates_presence_of :email
validates_format_of :email, :with => /^(|(([A-Za-z0-9]+_+)|([A-Za-z0-9]+\-+)|([A-Za-z0-9]+\.+)|([A-Za-z0-9]+\++))*[A-Za-z0-9][email protected]((\w+\-+)|(\w+\.))*\w{1,63}\.[a-zA-Z]{2,6})$/i
validates_numericality_of :student_id
validates_length_of :student_id, :minimum => 7, :maximum => 7
def online
self.registration.orientation != nil
end
def send_cancellation_email
generate_token(:registration_cancellation_token)
self.registration_cancelled_at = Time.zone.now
save!
NsoMailer.registration_cancellation_email(self).deliver
end
def self.send_reminder_emails
#NsoMailer.send_reminder_emails.deliver
registrations = Registration.where(orientation_id: Orientation.where(class_date: Date.today + 2))
registrations.each do |r|
NsoMailer.send_reminder_emails(r).deliver
end
end
def generate_token(column)
begin
self[column] = SecureRandom.urlsafe_base64
end while Registration.exists?(column => self[column])
end
end
는 앱/모델/registration.rb의 내용을 게시 할 수 ... 난 그냥
bundle exec rake send_reminder_emails
는 레이크 작업을 실행하는 실행 ... ... 같은보이는? – DiegoSalazar
OK ... registered.rb를 추가했습니다. – Lumbee
내 문제의 근원 인 것처럼 보입니다. 응용 프로그램이 내가 호출하고 있는데도로드되지 않습니다 : 환경. http://stackoverflow.com/questions/7044714/whats-the-environment-task-in-rake – Lumbee