我從1.8.x的不知道升級的Ruby 1.9.3如果小馬寶玉在這個過程過於升級,但問題是,我使用此代碼來發送電子郵件的如何不通過參數如果是空的?
Pony.mail(
:to => to,
:from => from,
:subject => subject,
:body => Nokogiri::HTML(body_with_footer).text,
:html_body => body_with_footer, #.gsub("\n","<BR>"),
:attachments => attachment_to_send,
:via => :smtp,
:via_options => {
:address => $smtp,
:port => $smtp_port,
:enable_starttls_auto => false
}
)
attachment_to_send應該是一個要附加的文件的哈希值。當散列爲空時,不發送附件。現在我得到一個小馬錯誤抱怨哈希是「」。
因此,我介紹瞭如果條件attachment_to_send==""
所以我打電話給小馬有或沒有附件部分。
有什麼辦法可以管理嗎?所以我只有一個代碼,我叫小馬?