Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix ActionMailer asset host in production. (#1044)
* Fix ActionMailer asset host in production (George) This change was originally made in a suspenders-based app to fix a problem we were having with images not rendering in emails. This commit replicates the fix upstream for future suspenders users. The change fixes image URLs in emails by adding a protocol to the ActionMailer asset_host setting. While the setting is called "host", based on the examples in the Rails documentation, it could be more accurately described as a "URL-prefix" -- all of the examples include a protocol as well as a host. Prior to this change, image URLs were generated in emails from production environments with a protocol-relative URL (e.g. //example.com/image.png), and were not rendering correctly in the various mail clients we tested. * Fix regex that removes comment lines from Rails config files (Thiago) That regex was causing the build to fail. The reason is that, when generating a new Suspenders app, it removed the new asset host config option introduced by George that contains a non-comment hashtag (#) character. Also, it was silently removing other lines of code that were being confused as Ruby comments just because they had hashtag characters somewhere (#) within them. Therefore, we are also fixing a bug here. Unfortunately, the regex is a simplistic approach because it does not factor in all possible Ruby comments. The only reliable way to remove comments involves some AST parsing in order to reliably detect comments and also preserve the general layout of the config files without aggressively removing blank lines. NOTE: The regex is buggy and may remove, for example, lines inside heredoc strings starting with a # character, among others. Thankfully, the config files we're dealing with here don't have such edge cases. Co-authored-by: Thiago A. Silva <[email protected]>
- Loading branch information