This project is archived and is in readonly mode.
Inheritable ActionMailer server settings
-
Will Bryant
As per Koz's suggestion on the mailing list, superclass_delegating_accessor works better - no test changes needed with that.
That in itself works fine.
However, trying to use it in a real project (2.2, at least) reveals a nasty oddity; if you access a mailer class in any way in your environment configuration (ie. production.rb), which is where config.action_mailer.smtp_settings is set and so would be the logical place to set YourSpecialMailer.smtp_settings also, then the YourSpecialMailer class gets loaded before the actionmailer view_paths have been set. As a result, you start getting weird ActionView::MissingTemplate exceptions like this:
Missing template your_special_mailer/template_that_actually_does_exist.erb in view path [RAILS_ROOT]/vendor/rails/actionpack/lib/action_view/template.rb:97:in `find_full_path'Fixing this is easy; we just need to change
class_inheritable_accessor :view_pathsTo:
superclass_delegating_accessor :view_pathsThis seems to work ok and solves that problem. Sound alright?
Patches attached.
-
Joe Noon
per_mailer_mailer_settings.diff is working well for me. +1 and nice fix.
-
José Valim
- Tag changed from actionmailer, inheritance, patch, smtp to actionmailer, bugmash, inheritance, patch, smtp
-
Josh Nichols
+1 on the functionality, but there are no tests to verify them.
I attached a patch that has failing tests (but no implementation). I tried Will's patch which uses superclass_delegating_accessor , but the tests still fail.
I used the originally proposed class_inheritable_accessor, and that does seem to work.
-
Rizwan Reza
- State changed from new to verified
- Tag changed from actionmailer, bugmash, inheritance, patch, smtp to actionmailer, inheritance, patch, smtp
- Milestone changed from 2.x to 2.3.6
I've verified the first patch, which applies cleanly.
-
José Valim
- State changed from verified to open
- Assigned user set to José Valim
- Milestone cleared.
We have ActionMailer refactoring going in a branch, so I'm tracking this ticket to add this behavior on it.
