Erwin
2011-Mar-17 18:07 UTC
Mailer template encoding error ( Spanish characters) not valid US-ASCII (obviously) ...
Some of my Mailer templates are in spanish, I get this error message : /usr/local/rvm/gems/ruby-1.9.2-p136@rails3/gems/actionpack-3.0.5/lib/ action_view/template/handlers/erb.rb:129:in `valid_encoding'': Your template was not saved as valid US-ASCII. Please either specify US- ASCII as the encoding for your template in your text editor, or mark the template with its encoding by inserting the following as the first line of the template: (ActionView::Template::Error) # encoding: <name of correct encoding>. The source of your template was: ... Recibes este mensaje porque has mandado un email a <%= @receiver %> PERDONA LA DEMORA Estamos actualizando la cantidad de registraciones regaladas. ... I coded the Notifier like this : class Notifier < ActionMailer::Base default :charset => "utf-8" .. mail(:to => destination, :subject => subject, :from => from) do |format| format.text(:content_transfer_encoding => "base64") format.html(:content_transfer_encoding => "base64") end but this doesn''t get rid of the error.... how & where should I write the encoding information -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Frederick Cheung
2011-Mar-17 18:54 UTC
Re: Mailer template encoding error ( Spanish characters) not valid US-ASCII (obviously) ...
On Mar 17, 6:07 pm, Erwin <yves_duf...-ee4meeAH724@public.gmane.org> wrote:> > class Notifier < ActionMailer::Base > default :charset => "utf-8" > .. > mail(:to => destination, :subject => subject, :from => from) > do |format| > format.text(:content_transfer_encoding => "base64") > format.html(:content_transfer_encoding => "base64") > end > > but this doesn''t get rid of the error.... how & where should I write > the encoding informationThat''s something else, it sets charset header on the outgoing message. What ruby 1.9 is complaining about is the encoding of your erb file. You need to do what the rails error message says and stick <%# encoding: utf-8 %> on the first line of your template (assuming utf-8 is what your template is written in) Fred -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Erwin
2011-Mar-18 06:55 UTC
Re: Mailer template encoding error ( Spanish characters) not valid US-ASCII (obviously) ...
Thanks Fred you mean it''s a Ruby 1.9 issue, not Rails... ( this is why I could not find any doc on it in Rails API... maybe ) and of course it happen only in plain-text template... I still do not understand why this error raised only when the script was run from the cron task ... and never when running the script from the command-line in the remote server console.... any idea on that ? On 17 mar, 19:54, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Mar 17, 6:07 pm, Erwin <yves_duf...-ee4meeAH724@public.gmane.org> wrote: > > > > > class Notifier < ActionMailer::Base > > default :charset => "utf-8" > > .. > > mail(:to => destination, :subject => subject, :from => from) > > do |format| > > format.text(:content_transfer_encoding => "base64") > > format.html(:content_transfer_encoding => "base64") > > end > > > but this doesn''t get rid of the error.... how & where should I write > > the encoding information > > That''s something else, it sets charset header on the outgoing message. > What ruby 1.9 is complaining about is the encoding of your erb file. > You need to do what the rails error message says and stick > > <%# encoding: utf-8 %> > > on the first line of your template (assuming utf-8 is what your > template is written in) > > Fred-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Erwin
2011-Mar-18 07:19 UTC
Re: Mailer template encoding error ( Spanish characters) not valid US-ASCII (obviously) ...
I read this post in forum, lot of info ... thanks it''s solved now .... http://www.ruby-forum.com/topic/374725 On 17 mar, 19:54, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Mar 17, 6:07 pm, Erwin <yves_duf...-ee4meeAH724@public.gmane.org> wrote: > > > > > class Notifier < ActionMailer::Base > > default :charset => "utf-8" > > .. > > mail(:to => destination, :subject => subject, :from => from) > > do |format| > > format.text(:content_transfer_encoding => "base64") > > format.html(:content_transfer_encoding => "base64") > > end > > > but this doesn''t get rid of the error.... how & where should I write > > the encoding information > > That''s something else, it sets charset header on the outgoing message. > What ruby 1.9 is complaining about is the encoding of your erb file. > You need to do what the rails error message says and stick > > <%# encoding: utf-8 %> > > on the first line of your template (assuming utf-8 is what your > template is written in) > > Fred-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.