Forum: Ruby on Rails Charset problems with partials

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
3b1daae9f655c5dba51ff1cdf03f1bef?d=identicon&s=25 Martin Stabenfeldt (Guest)
on 2007-06-22 16:27
(Received via mailing list)
Hi,

When using partials, I'm not able to keep the text posted as
ISO-8859-1, it changes to UTF-8.
The browser detects the page as ISO-8859-1, but I know the string from
the form is not
ISO-8859-1 when given to the method.

I'm able to keep the string as ISO-8859-1 if I don't use any partials or
RJS.



This is how the view with partials and RJS looks like:

main.rhtml
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    <head>
      <meta http-equiv="content-type"
content="text/html;charset=ISO-8859-1" />
      <title>Send it: <%= controller.action_name %></title>
      <%= stylesheet_link_tag 'nb' %>
    </head>
    <body>

    <%= render :partial => "publish" %>



_publish.rhtml
      <head>
        <meta http-equiv="Content-type" content="text/html;
charset=ISO-8859-1" />
      </head>
      <body>

    <%= form_remote_tag :url => { :action => 'publish' },
      :before => "Element.show('spinner');",
      :success => "show_results(xhr);",
      :failure => "show_error(xhr);",
      :complete => "Element.hide('spinner');",
      :html => { :id => 'thought-form' } %>

    <br>Message:<br>
    <%= text_area 'message', 'text', :maxlength => 60 %>

     <%= submit_tag 'Publish' %>
     <%= end_form_tag %>

    <div id="thoughts">
    </div>


publish.rjs:
    page.replace_html 'thoughts', :partial => 'status'
    page.visual_effect :highlight, 'thoughts'
    page.form.reset 'thought-form'

_status.rhtml
    <p>
      <p style="color: green"><%= flash[:notice] %></p>
      <p style="color: red"><%= flash[:warning] %></p>
    </p>



The code abow changes the input string to UTF-8, but the below does not.
How do I make sure the string is ISO-8859-1 through all of the
application?

plain_publish.rhtml
    <html xmlns="http://www.w3.org/1999/xhtml">
      <head>
        <meta http-equiv="Content-type" content="text/html;
charset=ISO-8859-1" />
      </head>
      <body>

    <%= form_tag :action => 'plainpublish' %>

    <br>Message:<br>
    <%= text_area 'message', 'text', :maxlength => 60 %>
    <%= submit_tag 'Publish' %>
    <%= end_form_tag %>


The methods are identical except for the name.

Any thoughts or suggestions are highly appreciated! :)


--
Regards,
Martin Stabenfeldt
C683c23bf52cfa8d2f672774c4fa5a41?d=identicon&s=25 Nicolas Escobar (nejrb)
on 2008-06-13 16:09
I have exactly the same problem, Martin.

Did you find out a way to solve this?

Thanks!
This topic is locked and can not be replied to.