Ruby on Rails Wednesday, November 19, 2014

On Nov 19, 2014, at 7:49 AM, Melb01 <melaggouni@gmail.com> wrote:

> Hi,
> I have problem with showing some string in my site with Rails 4
> I get this message:
> incompatible character encodings: ASCII-8BIT and UTF-8
>
> concerning this html sequence in an erb file:
> <h3><%= MyString.to_s.force_encoding("UTF-8") %></h3>
>
> I get this problem only on production server, but I do not have the problem on my local computer
> What can I do with this problem
>

At the top of this erb file, add the line:

# encoding: UTF-8

Make sure it is the very first line of the file. This will force the Ruby interpreter to read the page as unicode, no matter what format the file may actually be saved in (or mistaken for).

Walter

>
> regards,
>
> --
> You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
> To post to this group, send email to rubyonrails-talk@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/217f5775-1225-4759-84d5-b9a0d381aed3%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/58B943A0-F049-49AA-BE32-2E5A5A3E8E05%40wdstudio.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment