[Ruby] ApplicationHelper methods in ActionMailer templates
Scott Windsor
swindsor at gmail.com
Fri Jan 4 16:07:49 PST 2008
I remember it failing quite ungracefully, and was also frustrated by it
until I found the documentation. It would be really nice to have UrlWriting
included by default for your mailers, but I understand the problem of not
knowing which hostname to use.
Here's what I've been adding in my environment.rb (or initializers for rails
2).
require 'socket'
class ActionMailer::Base
include ActionController::UrlWriter
# override this for production!
default_url_options[:host] = Socket.gethostname
default_url_options[:port] = 3000
end
This gives you the hostname of your machine by default. This works great
for testing a development environment locally but *not at all* what you want
for production.
- scott
On Jan 4, 2008 3:24 PM, Ken Harris <kengruven at gmail.com> wrote:
> Hi Scott,
>
> Thanks! I did that in my environments/*.rb, and it seems to work (at
> least in testing).
>
> This is similar to one of the approaches I tried (and ran into an
> error), but hearing it somewhat authoritatively makes me feel much
> better about it!
>
>
> - Ken
> _______________________________________________
> Ruby at zenspider.com - Seattle.rb non-commercial list
> http://www.zenspider.com/seattle.rb
> http://www.zenspider.com/mailman/listinfo/ruby
>
More information about the Ruby
mailing list