2011-10-04 13 views

回答

3
在你的控制器動作

def example_action 
UserMailer.notifier(request.protocol, request.host_with_port).deliver 
end 

在notifier.html.erb視圖下方加入您的user_mailer文件類

def notifier(protocol, host) 
    @protocol = protocol 
    @host = host 
    mail(:from => "[email protected]", :to => "[email protected]", :subject => "Ur nice image path") 
end 

<%= image_tag("#{@protocol}#{@host}/images/image_name.xxx")%> 
+0

謝謝Sanankhalid。我在我的模型中發送郵件,我仍然可以從那裏訪問request.protocol和request.hot_with_port嗎? – chell

+0

你不能在你的模型中使用請求常量,你必須通過控制器發送這個請求。 –

相關問題