Reputation: 7866
I want to add images to an email template but don't want to add them inline but with the full path to their location on the server where the application is hosted.
How can I do this in Rails 3 action mailer?
Upvotes: 0
Views: 2114
Reputation: 3137
in your controller action
def example_action
UserMailer.notifier(request.protocol, request.host_with_port).deliver
end
add below in your user_mailer class
def notifier(protocol, host)
@protocol = protocol
@host = host
mail(:from => "[email protected]", :to => "[email protected]", :subject => "Ur nice image path")
end
in your notifier.html.erb view.
<%= image_tag("#{@protocol}#{@host}/images/image_name.xxx")%>
Upvotes: 3