This project is archived and is in readonly mode.
Setting the I18n.locale in ActionMailer raises SystemStackError
-
Don Werve
I've got the same problem, with a similar stack trace.
-
Maximilian Schulz
Ok, I should have google earlier… I have the exact same error. I moved my I18n.with_locale code out of the mail vier, as I have always got deprecation warnings for the block helper (although it does not make any sense). So my mailer looks like this:
I18n.in_locale(locale) do
mail :to => @user.to_email_recipient,:subject => I18n.t("new_message.subject", :title => @topic.subject)end
And it seems to work for some methods in the mailer and breaks on others. And I have no clue whats happening!
-
Maximilian Schulz
Ok, this is actually not a problem with the I18n.with_locale feature, but has to do with exceptions raised in the associated mail view. The with_locale call just hides the real error, which is really annoying!
-
Thiago Morello
I've got the same problem with "with_locale" method.
When sending using rails console everything works fine, but when calling from a controller I get the same error. -
aka47
- Assigned user set to José Valim
i also get this problem in rails 3.0.3 ... the locale= in abstract_controller/rendering.rb and this call action_view/lookup_context.rb and this call the first again. Endless loop.
# ree-1.8.7-2010.01@rails3/gems/actionpack-3.0.3/lib/abstract_controller/rendering.rb:28:in `locale=' # ree-1.8.7-2010.01@rails3/gems/actionpack-3.0.3/lib/action_view/lookup_context.rb:175:in `locale='José added a TODO to deprecate I18n.locale from controllers, but it does not say how the new api should is. I hope this will fix it.
I could fix it by removing the I18nProxy
# ree-1.8.7-2010.01@rails3/gems/actionpack-3.0.3/lib/abstract_controller/rendering.rb:39 + old_config, I18n.config = I18n.config, I18n.config - old_config, I18n.config = I18n.config, I18nProxy.new(I18n.config, lookup_context)or better patch it via config/initializer/rails3_abstract_controller_rendering_fix.rb
module AbstractController::Rendering def process(*) super end end -
José Valim
- State changed from new to needs-more-info
- Importance changed from to Low
I cannot reproduce. Could someone provide a test case to Action Mailer test suite?
-
Frank Fischer
I have the same problem using an I18n.locale call within the actionmailer method. The error triggers if the actionmailer-method is called from from inside a controller. Find a diff containing the testcase added.
Thank you Jose for pointing me in the right direction how to trigger the error in the testcase! -
f.svehla
- Tag changed from actionmailer, locale to actionmailer, i18n, infinity, locale
Simply calling I18n.locale= in an ActionMailer method is sufficient to trigger this bug.
-
f.svehla
- Title changed from Using I18n.with_locale in ActionMailer raises SystemStackError to Setting the I18n.locale in ActionMailer raises SystemStackError
-
Frank Fischer
@f.svhela: Can you provide a test case to prove your point? It's because I have one proving you are wrong ;). Btw. - This was the reason why Jose couldn't reproduce the error in first place.
-
eddyk
I can confirm seeing the stack problem when the mailer is created in a controller. In my unit tests, generating the email worked fine.
The monkey patch from aka47 appears to work.
{mkd-extraction-08d005cc18c52729bf1100e0f5943312}
module AbstractController::Rendering
def process(*)end end
-
Repository
- State changed from needs-more-info to resolved
(from [262b2ea8cda20999ddf8c4bf13b7a70453e996d2]) Solve SystemStackError when changing locale inside ActionMailer [#5329 Setting the I18n.locale in ActionMailer raises SystemStackError state:resolved] https://github.com/rails/rails/commit/262b2ea8cda20999ddf8c4bf13b7a...
-
Repository
(from [b247f3944282fb22c68fd4f9248a16fcda63b186]) Added a testcase for bug [#5329 Setting the I18n.locale in ActionMailer raises SystemStackError]
Signed-off-by: José Valim jose.valim@gmail.com
https://github.com/rails/rails/commit/b247f3944282fb22c68fd4f9248a1... -
Repository
(from [b4bc49c67388330a85a58cc790bbdb7edfa3ee80]) Added a testcase for bug [#5329 Setting the I18n.locale in ActionMailer raises SystemStackError]
Signed-off-by: José Valim jose.valim@gmail.com
https://github.com/rails/rails/commit/b4bc49c67388330a85a58cc790bbd... -
Repository
(from [46b23f8a7a6aec5066f740de16e6419828db8be4]) Solve SystemStackError when changing locale inside ActionMailer [#5329 Setting the I18n.locale in ActionMailer raises SystemStackError state:resolved] https://github.com/rails/rails/commit/46b23f8a7a6aec5066f740de16e64...
-
eddyk
module AbstractController class I18nProxy def initialize(i18n_config, lookup_context) @i18n_config, @lookup_context = i18n_config, lookup_context @i18n_config = @i18n_config.i18n_config if @i18n_config.respond_to?(:i18n_config) end end endHere's a bit a code my coworker came up with to prevent the infinite recursion that occurs when setting the I18n config in an actionmailer context, which is called from an actioncontroller.
