This project is archived and is in readonly mode.

#5329 ✓resolved
Jiří Zajpt

Setting the I18n.locale in ActionMailer raises SystemStackError

Reported by Jiří Zajpt | August 7th, 2010 @ 04:04 PM

When using I18n.with_locale function inside a function called from ActionMailer::Base, SystemStackError (stack level too deep) is raised. Also, simply changing locale with I18n.locale= results in the same exception. When using outside of ActionMailer, everything works as expected.

Stack trace:

SystemStackError (stack level too deep):
  /Users/jzajpt/.rvm/gems/ruby-1.8.7-p299@rails3/bundler/gems/rails-0953c04/actionpack/lib/action_view/lookup_context.rb:174:in `locale='
  /Users/jzajpt/.rvm/gems/ruby-1.8.7-p299@rails3/bundler/gems/rails-0953c04/actionpack/lib/abstract_controller/rendering.rb:28:in `locale='
  /Users/jzajpt/.rvm/gems/ruby-1.8.7-p299@rails3/bundler/gems/rails-0953c04/actionpack/lib/action_view/lookup_context.rb:175:in `locale='
  /Users/jzajpt/.rvm/gems/ruby-1.8.7-p299@rails3/bundler/gems/rails-0953c04/actionpack/lib/abstract_controller/rendering.rb:28:in `locale='
  /Users/jzajpt/.rvm/gems/ruby-1.8.7-p299@rails3/bundler/gems/rails-0953c04/actionpack/lib/action_view/lookup_context.rb:175:in `locale='
  /Users/jzajpt/.rvm/gems/ruby-1.8.7-p299@rails3/bundler/gems/rails-0953c04/actionpack/lib/abstract_controller/rendering.rb:28:in `locale='
  /Users/jzajpt/.rvm/gems/ruby-1.8.7-p299@rails3/bundler/gems/rails-0953c04/actionpack/lib/action_view/lookup_context.rb:175:in `locale='
  /Users/jzajpt/.rvm/gems/ruby-1.8.7-p299@rails3/bundler/gems/rails-0953c04/actionpack/lib/abstract_controller/rendering.rb:28:in `locale='
  /Users/jzajpt/.rvm/gems/ruby-1.8.7-p299@rails3/bundler/gems/rails-0953c04/actionpack/lib/action_view/lookup_context.rb:175:in `locale='
  /Users/jzajpt/.rvm/gems/ruby-1.8.7-p299@rails3/bundler/gems/rails-0953c04/actionpack/lib/abstract_controller/rendering.rb:28:in `locale='
  /Users/jzajpt/.rvm/gems/ruby-1.8.7-p299@rails3/bundler/gems/rails-0953c04/actionpack/lib/action_view/lookup_context.rb:175:in `locale='
  /Users/jzajpt/.rvm/gems/ruby-1.8.7-p299@rails3/bundler/gems/rails-0953c04/actionpack/lib/abstract_controller/rendering.rb:28:in `locale='
  /Users/jzajpt/.rvm/gems/ruby-1.8.7-p299@rails3/bundler/gems/rails-0953c04/actionpack/lib/action_view/lookup_context.rb:175:in `locale='
  /Users/jzajpt/.rvm/gems/ruby-1.8.7-p299@rails3/bundler/gems/rails-0953c04/actionpack/lib/abstract_controller/rendering.rb:28:in `locale='
….
  /Users/jzajpt/.rvm/gems/ruby-1.8.7-p299@rails3/bundler/gems/rails-0953c04/actionpack/lib/action_view/lookup_context.rb:175:in `locale='
  /Users/jzajpt/.rvm/gems/ruby-1.8.7-p299@rails3/bundler/gems/rails-0953c04/actionpack/lib/abstract_controller/rendering.rb:28:in `locale='
  i18n (0.4.1) lib/i18n.rb:39:in `locale='
  app/models/invoice_pdf.rb:26:in `to_pdf'
  /Users/jzajpt/.rvm/gems/ruby-1.8.7-p299@rails3/bundler/gems/rails-0953c04/activesupport/lib/active_support/dependencies.rb:442:in `each_with_index'
  app/models/invoice_pdf.rb:20:in `each'
  app/models/invoice_pdf.rb:20:in `each_with_index'
  app/models/invoice_pdf.rb:20:in `to_pdf'
  app/mailers/invoice_mailer.rb:6:in `email'
  /Users/jzajpt/.rvm/gems/ruby-1.8.7-p299@rails3/bundler/gems/rails-0953c04/actionpack/lib/abstract_controller/base.rb:148:in `send_action'
  /Users/jzajpt/.rvm/gems/ruby-1.8.7-p299@rails3/bundler/gems/rails-0953c04/actionpack/lib/abstract_controller/base.rb:148:in `process_action'
  /Users/jzajpt/.rvm/gems/ruby-1.8.7-p299@rails3/bundler/gems/rails-0953c04/actionpack/lib/abstract_controller/base.rb:117:in `process'
  /Users/jzajpt/.rvm/gems/ruby-1.8.7-p299@rails3/bundler/gems/rails-0953c04/actionpack/lib/abstract_controller/rendering.rb:40:in `process'
  /Users/jzajpt/.rvm/gems/ruby-1.8.7-p299@rails3/bundler/gems/rails-0953c04/actionmailer/lib/action_mailer/old_api.rb:75:in `process'
  /Users/jzajpt/.rvm/gems/ruby-1.8.7-p299@rails3/bundler/gems/rails-0953c04/actionmailer/lib/action_mailer/base.rb:446:in `process'
  /Users/jzajpt/.rvm/gems/ruby-1.8.7-p299@rails3/bundler/gems/rails-0953c04/actionmailer/lib/action_mailer/base.rb:441:in `initialize'
  /Users/jzajpt/.rvm/gems/ruby-1.8.7-p299@rails3/bundler/gems/rails-0953c04/actionmailer/lib/action_mailer/base.rb:425:in `new'
  /Users/jzajpt/.rvm/gems/ruby-1.8.7-p299@rails3/bundler/gems/rails-0953c04/actionmailer/lib/action_mailer/base.rb:425:in `method_missing'
  app/controllers/invoice_emails_controller.rb:20:in `create'
  /Users/jzajpt/.rvm/gems/ruby-1.8.7-p299@rails3/bundler/gems/rails-0953c04/actionpack/lib/action_controller/metal/implicit_render.rb:4:in `send_action'
  /Users/jzajpt/.rvm/gems/ruby-1.8.7-p299@rails3/bundler/gems/rails-0953c04/actionpack/lib/action_controller/metal/implicit_render.rb:4:in `send_action'
  /Users/jzajpt/.rvm/gems/ruby-1.8.7-p299@rails3/bundler/gems/rails-0953c04/actionpack/lib/abstract_controller/base.rb:148:in `process_action'
  /Users/jzajpt/.rvm/gems/ruby-1.8.7-p299@rails3/bundler/gems/rails-0953c04/actionpack/lib/action_controller/metal/rendering.rb:11:in `process_action'
  /Users/jzajpt/.rvm/gems/ruby-1.8.7-p299@rails3/bundler/gems/rails-0953c04/actionpack/lib/abstract_controller/callbacks.rb:18:in `process_action'
  /Users/jzajpt/.rvm/gems/ruby-1.8.7-p299@rails3/bundler/gems/rails-0953c04/activesupport/lib/active_support/callbacks.rb:445:in `_run__1023616770__process_action__1623385099__callbacks'
  /Users/jzajpt/.rvm/gems/ruby-1.8.7-p299@rails3/bundler/gems/rails-0953c04/activesupport/lib/active_support/callbacks.rb:404:in `send'
  /Users/jzajpt/.rvm/gems/ruby-1.8.7-p299@rails3/bundler/gems/rails-0953c04/activesupport/lib/active_support/callbacks.rb:404:in `_run_process_action_callbacks'
  /Users/jzajpt/.rvm/gems/ruby-1.8.7-p299@rails3/bundler/gems/rails-0953c04/activesupport/lib/active_support/callbacks.rb:93:in `send'
  /Users/jzajpt/.rvm/gems/ruby-1.8.7-p299@rails3/bundler/gems/rails-0953c04/activesupport/lib/active_support/callbacks.rb:93:in `run_callbacks'
  /Users/jzajpt/.rvm/gems/ruby-1.8.7-p299@rails3/bundler/gems/rails-0953c04/actionpack/lib/abstract_controller/callbacks.rb:17:in `process_action'
  /Users/jzajpt/.rvm/gems/ruby-1.8.7-p299@rails3/bundler/gems/rails-0953c04/actionpack/lib/action_controller/metal/instrumentation.rb:30:in `process_action'
  /Users/jzajpt/.rvm/gems/ruby-1.8.7-p299@rails3/bundler/gems/rails-0953c04/activesupport/lib/active_support/notifications.rb:52:in `instrument'
  /Users/jzajpt/.rvm/gems/ruby-1.8.7-p299@rails3/bundler/gems/rails-0953c04/activesupport/lib/active_support/notifications/instrumenter.rb:21:in `instrument'
  /Users/jzajpt/.rvm/gems/ruby-1.8.7-p299@rails3/bundler/gems/rails-0953c04/activesupport/lib/active_support/notifications.rb:52:in `instrument'
  /Users/jzajpt/.rvm/gems/ruby-1.8.7-p299@rails3/bundler/gems/rails-0953c04/actionpack/lib/action_controller/metal/instrumentation.rb:29:in `process_action'
  /Users/jzajpt/.rvm/gems/ruby-1.8.7-p299@rails3/bundler/gems/rails-0953c04/actionpack/lib/action_controller/metal/rescue.rb:17:in `process_action'
  /Users/jzajpt/.rvm/gems/ruby-1.8.7-p299@rails3/bundler/gems/rails-0953c04/actionpack/lib/abstract_controller/base.rb:117:in `process'
  /Users/jzajpt/.rvm/gems/ruby-1.8.7-p299@rails3/bundler/gems/rails-0953c04/actionpack/lib/abstract_controller/rendering.rb:40:in `process'
  /Users/jzajpt/.rvm/gems/ruby-1.8.7-p299@rails3/bundler/gems/rails-0953c04/actionpack/lib/action_controller/metal.rb:133:in `dispatch'
  /Users/jzajpt/.rvm/gems/ruby-1.8.7-p299@rails3/bundler/gems/rails-0953c04/actionpack/lib/action_controller/metal/rack_delegation.rb:14:in `dispatch'
  /Users/jzajpt/.rvm/gems/ruby-1.8.7-p299@rails3/bundler/gems/rails-0953c04/actionpack/lib/action_controller/metal.rb:173:in `action'
  /Users/jzajpt/.rvm/gems/ruby-1.8.7-p299@rails3/bundler/gems/rails-0953c04/actionpack/lib/action_dispatch/routing/route_set.rb:62:in `call'
  /Users/jzajpt/.rvm/gems/ruby-1.8.7-p299@rails3/bundler/gems/rails-0953c04/actionpack/lib/action_dispatch/routing/route_set.rb:62:in `dispatch'
  /Users/jzajpt/.rvm/gems/ruby-1.8.7-p299@rails3/bundler/gems/rails-0953c04/actionpack/lib/action_dispatch/routing/route_set.rb:27:in `call'
  rack-mount (0.6.9) lib/rack/mount/route_set.rb:148:in `call'
  rack-mount (0.6.9) lib/rack/mount/code_generation.rb:89:in `recognize'
  rack-mount (0.6.9) lib/rack/mount/code_generation.rb:87:in `optimized_each'
  rack-mount (0.6.9) lib/rack/mount/code_generation.rb:88:in `recognize'
  rack-mount (0.6.9) lib/rack/mount/route_set.rb:139:in `call'
  /Users/jzajpt/.rvm/gems/ruby-1.8.7-p299@rails3/bundler/gems/rails-0953c04/actionpack/lib/action_dispatch/routing/route_set.rb:492:in `call'
  haml (3.0.15) lib/sass/plugin/rack.rb:41:in `call'
  /Users/jzajpt/.rvm/gems/ruby-1.8.7-p299@rails3/bundler/gems/rails-0953c04/actionpack/lib/action_dispatch/middleware/best_standards_support.rb:8:in `call'
  /Users/jzajpt/.rvm/gems/ruby-1.8.7-p299@rails3/bundler/gems/rails-0953c04/actionpack/lib/action_dispatch/middleware/head.rb:14:in `call'
  rack (1.2.1) lib/rack/methodoverride.rb:24:in `call'
  /Users/jzajpt/.rvm/gems/ruby-1.8.7-p299@rails3/bundler/gems/rails-0953c04/actionpack/lib/action_dispatch/middleware/params_parser.rb:21:in `call'
  /Users/jzajpt/.rvm/gems/ruby-1.8.7-p299@rails3/bundler/gems/rails-0953c04/actionpack/lib/action_dispatch/middleware/flash.rb:177:in `call'
  /Users/jzajpt/.rvm/gems/ruby-1.8.7-p299@rails3/bundler/gems/rails-0953c04/actionpack/lib/action_dispatch/middleware/session/abstract_store.rb:149:in `call'
  /Users/jzajpt/.rvm/gems/ruby-1.8.7-p299@rails3/bundler/gems/rails-0953c04/actionpack/lib/action_dispatch/middleware/cookies.rb:268:in `call'
  /Users/jzajpt/.rvm/gems/ruby-1.8.7-p299@rails3/bundler/gems/rails-0953c04/actionpack/lib/action_dispatch/middleware/callbacks.rb:46:in `call'
  /Users/jzajpt/.rvm/gems/ruby-1.8.7-p299@rails3/bundler/gems/rails-0953c04/activesupport/lib/active_support/callbacks.rb:410:in `_run_call_callbacks'
  /Users/jzajpt/.rvm/gems/ruby-1.8.7-p299@rails3/bundler/gems/rails-0953c04/actionpack/lib/action_dispatch/middleware/callbacks.rb:44:in `call'
  rack (1.2.1) lib/rack/sendfile.rb:107:in `call'
  /Users/jzajpt/.rvm/gems/ruby-1.8.7-p299@rails3/bundler/gems/rails-0953c04/actionpack/lib/action_dispatch/middleware/remote_ip.rb:48:in `call'
  /Users/jzajpt/.rvm/gems/ruby-1.8.7-p299@rails3/bundler/gems/rails-0953c04/actionpack/lib/action_dispatch/middleware/show_exceptions.rb:48:in `call'
  /Users/jzajpt/.rvm/gems/ruby-1.8.7-p299@rails3/bundler/gems/rails-0953c04/railties/lib/rails/rack/logger.rb:13:in `call'
  rack (1.2.1) lib/rack/runtime.rb:17:in `call'
  /Users/jzajpt/.rvm/gems/ruby-1.8.7-p299@rails3/bundler/gems/rails-0953c04/activesupport/lib/active_support/cache/strategy/local_cache.rb:72:in `call'
  rack (1.2.1) lib/rack/lock.rb:11:in `call'
  rack (1.2.1) lib/rack/lock.rb:11:in `synchronize'
  rack (1.2.1) lib/rack/lock.rb:11:in `call'
  /Users/jzajpt/.rvm/gems/ruby-1.8.7-p299@rails3/bundler/gems/rails-0953c04/actionpack/lib/action_dispatch/middleware/static.rb:30:in `call'
  /Users/jzajpt/.rvm/gems/ruby-1.8.7-p299@rails3/bundler/gems/rails-0953c04/railties/lib/rails/application.rb:168:in `call'
  /Users/jzajpt/.rvm/gems/ruby-1.8.7-p299@rails3/bundler/gems/rails-0953c04/railties/lib/rails/application.rb:77:in `send'
  /Users/jzajpt/.rvm/gems/ruby-1.8.7-p299@rails3/bundler/gems/rails-0953c04/railties/lib/rails/application.rb:77:in `method_missing'
  /Users/jzajpt/.rvm/gems/ruby-1.8.7-p299@rails3/bundler/gems/rails-0953c04/railties/lib/rails/rack/log_tailer.rb:14:in `call'
  rack (1.2.1) lib/rack/content_length.rb:13:in `call'
  rack (1.2.1) lib/rack/handler/webrick.rb:52:in `service'
  /Users/jzajpt/.rvm/rubies/ruby-1.8.7-p299/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
  /Users/jzajpt/.rvm/rubies/ruby-1.8.7-p299/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
  /Users/jzajpt/.rvm/rubies/ruby-1.8.7-p299/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
  /Users/jzajpt/.rvm/rubies/ruby-1.8.7-p299/lib/ruby/1.8/webrick/server.rb:162:in `start'
  /Users/jzajpt/.rvm/rubies/ruby-1.8.7-p299/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
  /Users/jzajpt/.rvm/rubies/ruby-1.8.7-p299/lib/ruby/1.8/webrick/server.rb:95:in `start'
  /Users/jzajpt/.rvm/rubies/ruby-1.8.7-p299/lib/ruby/1.8/webrick/server.rb:92:in `each'
  /Users/jzajpt/.rvm/rubies/ruby-1.8.7-p299/lib/ruby/1.8/webrick/server.rb:92:in `start'
  /Users/jzajpt/.rvm/rubies/ruby-1.8.7-p299/lib/ruby/1.8/webrick/server.rb:23:in `start'
  /Users/jzajpt/.rvm/rubies/ruby-1.8.7-p299/lib/ruby/1.8/webrick/server.rb:82:in `start'
  rack (1.2.1) lib/rack/handler/webrick.rb:13:in `run'
  rack (1.2.1) lib/rack/server.rb:213:in `start'
  /Users/jzajpt/.rvm/gems/ruby-1.8.7-p299@rails3/bundler/gems/rails-0953c04/railties/lib/rails/commands/server.rb:65:in `start'
  /Users/jzajpt/.rvm/gems/ruby-1.8.7-p299@rails3/bundler/gems/rails-0953c04/railties/lib/rails/commands.rb:30
  /Users/jzajpt/.rvm/gems/ruby-1.8.7-p299@rails3/bundler/gems/rails-0953c04/railties/lib/rails/commands.rb:27:in `tap'
  /Users/jzajpt/.rvm/gems/ruby-1.8.7-p299@rails3/bundler/gems/rails-0953c04/railties/lib/rails/commands.rb:27
  script/rails:6:in `require'
  script/rails:6

Rendered /Users/jzajpt/.rvm/gems/ruby-1.8.7-p299@rails3/bundler/gems/rails-0953c04/actionpack/lib/action_dispatch/middleware/templates/rescues/_trace.erb (89.7ms)
Rendered /Users/jzajpt/.rvm/gems/ruby-1.8.7-p299@rails3/bundler/gems/rails-0953c04/actionpack/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb (76.0ms)
Rendered /Users/jzajpt/.rvm/gems/ruby-1.8.7-p299@rails3/bundler/gems/rails-0953c04/actionpack/lib/action_dispatch/middleware/templates/rescues/diagnostics.erb within rescues/layout (175.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>

Attachments

Referenced by

Pages