require 'action_view/helpers/url_helper'
class UserMailer < ActionMailer::Base
include ActionView::Helpers::UrlHelper
helper_method :url_for
helper_method :link_to
def welcome_email(user)
...
end
end
That doesn't seem to work. What is the right way to deal with this?
See the section on "Generating URLs": http://api.rubyonrails.org/classes/ActionMailer/Base.html
ActionMailer::Base.default_url_options[:host] = "example.com"
Brandon
http://drawohara.com/post/337775636/rails-relative-links-in-mailers-the-un-sucky-way
Best,
Michael Guterl
config.action_mailer.default_url_options = { :host =>
'mydomain.local' }
The problem is not that the url's are relative vs. absolute, it's that
"url_for" is undefined in my mailer template's scope:
failed with ActionView::TemplateError: undefined method `url_for'
This did work when sending the mail inline. The issue only cropped up
when switching it to delayed_job.
On Apr 12, 12:32 pm, Michael Guterl <mgut...@gmail.com> wrote:
> http://drawohara.com/post/337775636/rails-relative-links-in-mailers-t...
>
> Best,
> Michael Guterl
class UserMailer < ActionMailer::Base
helper ActionView::Helpers::UrlHelper
def welcome_email(user)
...
end
end
I was using "helper_method" instead of "helper". Makes a big
difference. http://apidock.com/rails/ActionMailer/Helpers/ClassMethods/helper
I guess rails put everything I needed into scope for me when sending
mail during the response. Just figured I'd post my findings for the
next guy who has this issue.