asset_host and ActionMailer

After digging through the rails code to figure out why my asset_host wasn't getting applied to emails, I realized that it's because the config object in the context of a mailer is config.action_mailer and not config.action_controller. This means you need to set asset host separately for emails, as config.action_mailer.asset_host.

Should this be considered a bug? Is it really logical to have them separated like that, or would it make more sense to have a simple config.asset_host ? If it's not a bug, it needs to be at least documented, as there's no mention of this anywhere within action mailer or in asset tag helper

I think that, if I have followed the discussions aright, the idea is that action_mailer (and perhaps action_resource and active_record) are being decoupled from action_controller as much as possible. That said, it seems to me a sensible compromise is that:

1. If config.action_controller.whatever is not nil 2. and config.action_mailer.whatever is nil 3. then config.action_mailer.whatever should use config.action_controller.whatever as a default

This approach could be extended to all of the action_ and active_ components.

WDYT?

Totally agree.

Robert Pankowecki

For both action_controller and action_mailer, it would make more sense to fallback to whatever is in abstract_controller. I'm not sure there is a config.abstract_controller, though.

Jeremy

I think that, if I have followed the discussions aright, the idea is that action_mailer (and perhaps action_resource and active_record) are being decoupled from action_controller as much as possible. That said, it seems to me a sensible compromise is that:

1. If config.action_controller.whatever is not nil 2. and config.action_mailer.whatever is nil 3. then config.action_mailer.whatever should use config.action_controller.whatever as a default

This approach could be extended to all of the action_ and active_ components.

For both action_controller and action_mailer, it would make more sense to fallback to whatever is in abstract_controller. I'm not sure there is a config.abstract_controller, though.

Jeremy

I also think they should both fallback to a common setting, rather than action_mailer falling back to action_controller. config.abstract_controller makes a certain amount of sense, but it'll probably be a bit confusing to those who don't fully understand rail's class structure. How about simply defining config.asset_host ?

I believe this has been fixed in Rails master. Have you tried?