This project is archived and is in readonly mode.

#3941 ✓resolved
imo

"invalid byte sequence in US-ASCII" error for UTF-8 localized messages

Reported by imo | February 12th, 2010 @ 01:34 PM

Localized UTF error messages generate "invalid byte sequence in US-ASCII" exception when trying to save it.

Versions:
rails - 3.0.0.beta1 from git repo

$ /usr/local/bin/ruby -v
ruby 1.9.1p376 (2009-12-07 revision 26041) [i686-linux]

Steps to reporoduce:

$ git clone git://github.com/rails/rails.git
$ /usr/local/bin/ruby rails/railties/bin/rails yyy
$ cd yyy
in Gemfile change 3rd line to:
gem 'rails', :path => '/home/imo/rails'
$ ~/.gem/ruby/1.9.1/bin/bundle install
$ ./script/rails g scaffold post title:string body:text published:boolean
in app/model/post.rb add:
  validates_length_of :title, :minimum => 4
in config/application.rb add:
  config.i18n.default_locale = :pl
$ cat > config/locales/pl.yml
pl:
 activerecord:
  errors:
   messages:

too_short: "jest za krótkie (minimalnie {{count}} znaków)"



^D $ rake db:migrate $ ./script/rails s open url localhost:3000/posts/new hit button "Create Post" I'm getting ArgumentError in Posts#create

after removing all silencers
(add Rails.backtrace_cleaner.remove_silencers! to config/initializers/backtrace_silencers.rb) I have such backtrace:

Started POST "/posts" for 127.0.0.1 at 2010-02-12 14:16:25
  Processing by PostsController#create as HTML
  Parameters: {"authenticity_token"=>"cTfBRCsNEVxBTjsxLEyKqeAyaoeJ6jSUkX21vb0bb3I=", "post"=>{"title"=>"", "body"=>"", "published"=>"0"}, "commit"=>"Create Post"}

ActionView::Template::Error (invalid byte sequence in US-ASCII) on line #2 of /home/imo/yyy/app/views/posts/_form.html.erb:
1: <% form_for(@post) do |f| %>
2:   <%= f.error_messages %>
3: 
4:   <div class="field">
5:     <%= f.label :title %><br />

    /home/imo/rails/activesupport/lib/active_support/core_ext/string/output_safety.rb:22:in `gsub'
    /home/imo/rails/activesupport/lib/active_support/core_ext/string/output_safety.rb:22:in `html_escape'
    /home/imo/rails/actionpack/lib/action_view/helpers/active_model_helper.rb:229:in `block (3 levels) in error_messages_for'
    /home/imo/rails/actionpack/lib/action_view/helpers/active_model_helper.rb:228:in `map'
    /home/imo/rails/actionpack/lib/action_view/helpers/active_model_helper.rb:228:in `block (2 levels) in error_messages_for'
    /home/imo/rails/activesupport/lib/active_support/core_ext/enumerable.rb:59:in `map'
    /home/imo/rails/activesupport/lib/active_support/core_ext/enumerable.rb:59:in `sum'
    /home/imo/rails/actionpack/lib/action_view/helpers/active_model_helper.rb:227:in `block in error_messages_for'
    /home/imo/rails/activesupport/lib/active_support/core_ext/object/with_options.rb:22:in `with_options'
    /home/imo/rails/actionpack/lib/action_view/helpers/active_model_helper.rb:218:in `error_messages_for'
    /home/imo/rails/actionpack/lib/action_view/helpers/form_helper.rb:1106:in `error_messages'
    app/views/posts/_form.html.erb:2:in `block in _render_template_489766511_80078656_769562'
    /home/imo/rails/actionpack/lib/action_view/helpers/form_helper.rb:532:in `fields_for'
    /home/imo/rails/actionpack/lib/action_view/helpers/form_helper.rb:313:in `form_for'
    app/views/posts/_form.html.erb:1:in `_render_template_489766511_80078656_769562'
    /home/imo/rails/actionpack/lib/action_view/template.rb:40:in `render'
    /home/imo/rails/actionpack/lib/action_view/render/partials.rb:285:in `render_partial'
    /home/imo/rails/actionpack/lib/action_view/render/partials.rb:225:in `block in render'
    /home/imo/rails/activesupport/lib/active_support/notifications/instrumenter.rb:18:in `instrument'
    /home/imo/rails/activesupport/lib/active_support/notifications.rb:49:in `instrument'
    /home/imo/rails/actionpack/lib/action_view/render/partials.rb:223:in `render'
    /home/imo/rails/actionpack/lib/action_view/render/partials.rb:347:in `_render_partial'
    /home/imo/rails/actionpack/lib/action_view/render/rendering.rb:43:in `render'
    app/views/posts/new.html.erb:3:in `_render_template_33817705_80151512_0'
    /home/imo/rails/actionpack/lib/action_view/template.rb:40:in `render'
    /home/imo/rails/actionpack/lib/action_view/render/rendering.rb:101:in `block in _render_template'
    /home/imo/rails/activesupport/lib/active_support/notifications/instrumenter.rb:18:in `instrument'
    /home/imo/rails/activesupport/lib/active_support/notifications.rb:49:in `instrument'
    /home/imo/rails/actionpack/lib/action_view/render/rendering.rb:98:in `_render_template'
    /home/imo/rails/actionpack/lib/action_view/render/rendering.rb:92:in `render_template'
    /home/imo/rails/actionpack/lib/abstract_controller/rendering.rb:84:in `_render_template'
    /home/imo/rails/actionpack/lib/abstract_controller/rendering.rb:65:in `render_to_body'
    /home/imo/rails/actionpack/lib/abstract_controller/layouts.rb:308:in `render_to_body'
    /home/imo/rails/actionpack/lib/action_controller/metal/rendering.rb:28:in `render_to_body'
    /home/imo/rails/actionpack/lib/action_controller/metal/renderers.rb:46:in `render_to_body'
    /home/imo/rails/actionpack/lib/action_controller/metal/compatibility.rb:115:in `render_to_body'
    /home/imo/rails/actionpack/lib/abstract_controller/rendering.rb:49:in `render'
    /home/imo/rails/actionpack/lib/action_controller/metal/rendering.rb:21:in `render'
    /home/imo/rails/actionpack/lib/abstract_controller/localized_cache.rb:39:in `render'
    /home/imo/rails/actionpack/lib/action_controller/metal/instrumentation.rb:39:in `block (2 levels) in render'
    /home/imo/rails/activesupport/lib/active_support/core_ext/benchmark.rb:17:in `block in ms'
    /usr/local/lib/ruby/1.9.1/benchmark.rb:309:in `realtime'
    /home/imo/rails/activesupport/lib/active_support/core_ext/benchmark.rb:17:in `ms'
    /home/imo/rails/actionpack/lib/action_controller/metal/instrumentation.rb:39:in `block in render'
    /home/imo/rails/actionpack/lib/action_controller/metal/instrumentation.rb:77:in `cleanup_view_runtime'
    /home/imo/rails/activerecord/lib/active_record/railties/controller_runtime.rb:15:in `cleanup_view_runtime'
    /home/imo/rails/actionpack/lib/action_controller/metal/instrumentation.rb:38:in `render'
    app/controllers/posts_controller.rb:50:in `block (2 levels) in create'
    /home/imo/rails/actionpack/lib/action_controller/metal/mime_responds.rb:189:in `call'
    /home/imo/rails/actionpack/lib/action_controller/metal/mime_responds.rb:189:in `respond_to'
    app/controllers/posts_controller.rb:45:in `create'
    /home/imo/rails/actionpack/lib/action_controller/base.rb:44:in `send'
    /home/imo/rails/actionpack/lib/action_controller/base.rb:44:in `send_action'
    /home/imo/rails/actionpack/lib/abstract_controller/base.rb:145:in `process_action'
    /home/imo/rails/actionpack/lib/abstract_controller/callbacks.rb:18:in `block in process_action'
    /home/imo/rails/activesupport/lib/active_support/callbacks.rb:433:in `_run__978314271__process_action__738868751__callbacks'
    /home/imo/rails/activesupport/lib/active_support/callbacks.rb:423:in `_run_process_action_callbacks'
    /home/imo/rails/activesupport/lib/active_support/callbacks.rb:88:in `run_callbacks'
    /home/imo/rails/actionpack/lib/abstract_controller/callbacks.rb:17:in `process_action'
    /home/imo/rails/actionpack/lib/action_controller/metal/rendering.rb:12:in `process_action'
    /home/imo/rails/actionpack/lib/action_controller/metal/compatibility.rb:66:in `process_action'
    /home/imo/rails/actionpack/lib/action_controller/metal/instrumentation.rb:29:in `block in process_action'
    /home/imo/rails/activesupport/lib/active_support/notifications/instrumenter.rb:18:in `instrument'
    /home/imo/rails/activesupport/lib/active_support/notifications.rb:49:in `instrument'
    /home/imo/rails/actionpack/lib/action_controller/metal/instrumentation.rb:28:in `process_action'
    /home/imo/rails/actionpack/lib/action_controller/metal/rescue.rb:8:in `process_action'
    /home/imo/rails/actionpack/lib/abstract_controller/base.rb:115:in `process'
    /home/imo/rails/actionpack/lib/action_controller/metal.rb:64:in `dispatch'
    /home/imo/rails/actionpack/lib/action_controller/metal/rack_delegation.rb:19:in `dispatch'
    /home/imo/rails/actionpack/lib/action_controller/metal.rb:89:in `call'
    /home/imo/rails/actionpack/lib/action_dispatch/routing/route_set.rb:27:in `call'
    rack-mount (0.5.0) lib/rack/mount/recognition/route_set.rb:75:in `block in call'
    rack-mount (0.5.0) lib/rack/mount/recognition/code_generation.rb:99:in `block in recognize'
    rack-mount (0.5.0) lib/rack/mount/recognition/code_generation.rb:76:in `optimized_each'
    rack-mount (0.5.0) lib/rack/mount/recognition/code_generation.rb:98:in `recognize'
    rack-mount (0.5.0) lib/rack/mount/recognition/route_set.rb:66:in `call'
    /home/imo/rails/actionpack/lib/action_dispatch/routing/route_set.rb:420:in `call'
    /home/imo/rails/activerecord/lib/active_record/query_cache.rb:29:in `block in call'
    /home/imo/rails/activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb:34:in `cache'
    /home/imo/rails/activerecord/lib/active_record/query_cache.rb:9:in `cache'
    /home/imo/rails/activerecord/lib/active_record/query_cache.rb:28:in `call'
    /home/imo/rails/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb:365:in `call'
    /home/imo/rails/actionpack/lib/action_dispatch/middleware/head.rb:14:in `call'
    /home/imo/rails/rack/lib/rack/methodoverride.rb:24:in `call'
    /home/imo/rails/actionpack/lib/action_dispatch/middleware/params_parser.rb:20:in `call'
    /home/imo/rails/actionpack/lib/action_dispatch/middleware/flash.rb:167:in `call'
    /home/imo/rails/actionpack/lib/action_dispatch/middleware/session/cookie_store.rb:107:in `call'
    /home/imo/rails/actionpack/lib/action_dispatch/middleware/cookies.rb:205:in `call'
    /home/imo/rails/actionpack/lib/action_dispatch/middleware/callbacks.rb:46:in `block in call'
    /home/imo/rails/activesupport/lib/active_support/callbacks.rb:429:in `_run_call_callbacks'
    /home/imo/rails/activesupport/lib/active_support/callbacks.rb:88:in `run_callbacks'
    /home/imo/rails/actionpack/lib/action_dispatch/middleware/callbacks.rb:44:in `call'
    /home/imo/rails/actionpack/lib/action_dispatch/middleware/show_exceptions.rb:62:in `call'
    /home/imo/rails/railties/lib/rails/rack/logger.rb:13:in `call'
    /home/imo/rails/rack/lib/rack/runtime.rb:17:in `call'
    /home/imo/rails/rack/lib/rack/lock.rb:11:in `block in call'
    <internal:prelude>:8:in `synchronize'
    /home/imo/rails/rack/lib/rack/lock.rb:11:in `call'
    /home/imo/rails/actionpack/lib/action_dispatch/middleware/static.rb:30:in `call'
    /home/imo/rails/railties/lib/rails/application.rb:95:in `call'
    /home/imo/rails/railties/lib/rails/application.rb:41:in `method_missing'
    /home/imo/rails/railties/lib/rails/rack/log_tailer.rb:15:in `call'
    /home/imo/rails/rack/lib/rack/content_length.rb:13:in `call'
    /home/imo/rails/rack/lib/rack/handler/webrick.rb:48:in `service'
    /usr/local/lib/ruby/1.9.1/webrick/httpserver.rb:111:in `service'
    /usr/local/lib/ruby/1.9.1/webrick/httpserver.rb:70:in `run'
    /usr/local/lib/ruby/1.9.1/webrick/server.rb:183:in `block in start_thread'

Rendered /home/imo/rails/actionpack/lib/action_dispatch/middleware/templates/rescues/_trace.erb (1.4ms)
Rendered /home/imo/rails/actionpack/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb (8.9ms)
Rendered /home/imo/rails/actionpack/lib/action_dispatch/middleware/templates/rescues/template_error.erb within /home/imo/rails/actionpack/lib/action_dispatch/middleware/templates/rescues/layout.erb (20.8ms)

Comments and changes to this ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

People watching this ticket

Attachments

Referenced by

Pages