Ruby 2.3 + Rails 5 = RuntimeError: can't modify frozen String
Nowaker opened this issue · comments
Damian Nowak commented
Standard code to send email:
mail(headers) do |format|
format.html { render text: email_text }
end
RuntimeError: can't modify frozen String
/home/nowaker/.rvm/gems/ruby-2.3.3/gems/mailkick-0.1.5/lib/mailkick/processor.rb:23:in `gsub!'
/home/nowaker/.rvm/gems/ruby-2.3.3/gems/mailkick-0.1.5/lib/mailkick/processor.rb:23:in `block in process'
/home/nowaker/.rvm/gems/ruby-2.3.3/gems/mailkick-0.1.5/lib/mailkick/processor.rb:22:in `each'
/home/nowaker/.rvm/gems/ruby-2.3.3/gems/mailkick-0.1.5/lib/mailkick/processor.rb:22:in `process'
/home/nowaker/.rvm/gems/ruby-2.3.3/gems/mailkick-0.1.5/lib/mailkick/mailer.rb:6:in `block in mail'
/home/nowaker/.rvm/gems/ruby-2.3.3/gems/safely_block-0.1.1/lib/safely/core.rb:40:in `safely'
/home/nowaker/.rvm/gems/ruby-2.3.3/gems/mailkick-0.1.5/lib/mailkick/mailer.rb:6:in `mail'
./engines/hosting/app/mailers/billing_mailer.rb:35:in `new_machine_on_existing_subscription'
Rails 5 has done a lot of optimizations in how strings are handled and this might be the reason why this fails.
Damian Nowak commented
It's actually not Rails 5 related. mail gem has enabled frozen string literals for all their code: https://github.com/mikel/mail/pull/970/files You shouldn't modify any strings that are part of mail gem structures, like raw_source
.
Andrew Kane commented
Fixed with #21