This project is archived and is in readonly mode.
compute_asset_host bombs when asset_host = Proc and called from a Mailer
Reported by Tekin | November 17th, 2008 @ 09:59 PM | in 2.x
compute_asset_host is falling over when used in Mailer views under certain conditions.
If you set asset_host to a 2 arguement Proc, compute_asset_host calls the Proc, passing in the source and the request object. Problem is, Mailer objects will not have a request object so compute_asset_host falls over with an undefined method error.
This simple patch updates compute_asset_host to pass nil in place of the request if no request is present. This way, you can write your Proc to cope with a nil request if necessary.
Comments and changes to this ticket
-
Michael Koziarski November 18th, 2008 @ 06:28 PM
Can you also provide a test for actionmailer which shows the problem?
Would help avoid regressions and make the changeset a little more obvious.
-
Tekin November 18th, 2008 @ 06:35 PM
Yeah, sorry, had been a long day. Will get a proper patch in asap.
-
Tekin November 20th, 2008 @ 11:27 PM
Just looking into this a bit more, although it's still not right that compute_asset_host falls over in mailer templates when asset_host is set to a 2 arguement Proc, it seems the primary reason you'd use a Proc this way would be to provide an alternative host for SSL requests.
I'm just wondering, would it make more sense to be able to explicitly specify an optional SSL specific host?
config.action_controller.ssl_asset_host = "https://www.example.com"
That would certainly scratch my itch. What do you think?
-
Tekin November 25th, 2008 @ 11:38 AM
Here are some tests, including one that fails.
Although my patch fixes the problem, long term, I'm not convinced it's the right solution. The second argument was only really introduced to help deal with SSL:
http://dev.rubyonrails.org/ticke...
Long term, I think it make sense to depreciate this second parameter and add ssl_asset_host as an option to ActionController::Base. Unless there is a use case for the request arguement that I am missing?
-
Repository December 1st, 2008 @ 06:39 PM
- State changed from new to committed
(from [dab78e55cfcc111b898a1c2475c0c5c327db30f9]) Ensure ActionMailer doesn't blow up when a two argument proc is set for the asset host
Signed-off-by: Michael Koziarski michael@koziarski.com [#1394 state:committed] http://github.com/rails/rails/co...
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
<h2 style="font-size: 14px">Tickets have moved to Github</h2>
The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>
People watching this ticket
Attachments
Referenced by
- 1394 compute_asset_host bombs when asset_host = Proc and called from a Mailer Signed-off-by: Michael Koziarski michael@koziarski.com [#...