[Ruby] ApplicationHelper methods in ActionMailer templates

Ryan Kuykendall ryank at jobster.com
Fri Jan 4 16:22:10 PST 2008


There's a Rails plugin that does this in conjunction with an around  
filter too:

http://www.pivotalblabs.com/articles/2007/08/20/how-i-leaned-to-stop- 
hating-and-love-action-mailer

Ryan

On Jan 4, 2008, at 4:07 PM, Scott Windsor wrote:

> 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
>>
> _______________________________________________
> 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