upgrade - rails actionmailer error with 'part' method -
i'm upgrading rails 2.3.2 app ot rails 3. have unknown error sending email message in mailerformerror. mailerformerror model: class mailerformerror < actionmailer::base
at 1st have error 'deliver_send' method (undefined method `deliver_sent' mailerformerror:class), change 'send'. have this:
nomethoderror in leadscontroller#create undefined method `part' #
my code in controller:
@msg = {} @msg["errors"] = @lead.errors @msg["params"] = params #mailerformerror.deliver_sent(@msg) mailerformerror.sent(@msg)
this class sending method:
def sent(msg, sent_at = time.now) @subject = ("Ошибка при заполнении формы").force_encoding('iso-8859-1').encode('utf-8') @recipients = 'mymail@gmail.com' @from = 'mymail@gmail.com' @sent_on = sent_at @headers = {} part( :content_type => "multipart/alternative" ) |p| p.part :content_type => "text/plain", :body => render_message("sent.plain.erb", :msg=>msg ) end end
1) rails 3, send notification in controller , have write :
mailerformerror.sent(@msg).deliver
2) , have rewrite 'sent' method in rails 3 way :
def sent(msg, sent_at = time.now) ... mail(:to => '...', :from => '...', :subject => '...') |format| format.html format.text end ... end
you can create text version , html in view directory app/views/mail_form_error : sent.text.erb , sent.html.erb
Comments
Post a Comment