ruby on rails - uninitialized constant mailer DEFAULT_FROM -



ruby on rails - uninitialized constant mailer DEFAULT_FROM -

it seems when run application in production mode getting next within console:

/home/desktop/portal/app/mailers/holiday_mailer.rb:2:in `<class:holidaymailer>': uninitialized constant holidaymailer::default_from (nameerror)

i have looked @ next question rails 3 action mailer uninitialized constant. appears have not made error set followed:

environment.rb

require file.expand_path('../application', __file__) # initialize rails application portal::application.initialize! actionmailer::base.delivery_method = :smtp default_from = "portal@gmail.com"

holiday mailer

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

holiday controller

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 user tell them state of holiday holidaymailer.holiday_confirmation(holiday).deliver else render 'edit' end end

it seems though wrong

i don't know why throwing error in production, can tell how prepare problem.

i replicated scenario in rails 3.2.11 app , got same error in production. there 2 possible fixes.

move variable default_from environments/production.rb

make initializer file mail service settings (config/initializers/mail_settings.rb) , set variable default_from in file.

the sec approach neat, because configuration mailer , variable available in both development , production environments. both these approaches require restart dev/deployment server.

hope helps.

ruby-on-rails actionmailer

Comments

Popular posts from this blog

web services - java.lang.NoClassDefFoundError: Could not initialize class net.sf.cglib.proxy.Enhancer -

Accessing MATLAB's unicode strings from C -

javascript - mongodb won't find my schema method in nested container -