0
看來,當我跑我在生產模式下的應用,我讓我的控制檯中執行以下操作:未初始化的常量郵件DEFAULT_FROM
/home/Desktop/Portal/app/mailers/holiday_mailer.rb:2:in
`<class:HolidayMailer>': uninitialized constant HolidayMailer::DEFAULT_FROM (NameError)
我已經看着下面SO質疑Rails 3 Action Mailer uninitialized constant。看來,我的設立是遵循我沒有犯了那個錯誤:
的environment.rb
require File.expand_path('../application', __FILE__)
# Initialize the rails application
Portal::Application.initialize!
ActionMailer::Base.delivery_method = :smtp
DEFAULT_FROM = "[email protected]"
假期郵件
class HolidayMailer < ActionMailer::Base
default :from => DEFAULT_FROM
def holiday_confirmation(holiday)
@holiday = holiday
mail(:to => holiday.user.email, :subject => "Your Absence Request")
end
end
假日控制器
def update()
admin = User.find(current_user.role? :administrator)
holiday = Holiday.find(params[:id])
user = User.find(id = holiday.user_id)
if holiday.update_attributes(params[:holiday])
if holiday.state == "approved"
user.absentdays = user.absentdays - (holiday.days_used).to_i
user.save
end
redirect_to absence_path, :notice => "request updated!"
#email the user to tell them the state of their holiday
HolidayMailer.holiday_confirmation(holiday).deliver
else
render 'edit'
end
end
看起來雖然這是錯誤的
第二個選項到最後,你的權利它更清潔的方式歡呼 – David 2013-02-13 04:01:41