ここで controller.rb を呼び出した後、1 つのファイル (chart.png) が私の rails app フォルダーに保存されるので、これをどのように取得してメールに添付しますか?
controller.rb
def mail
@imageURL = "https://chart.googleapis.com/chart?chs=150x150&cht=qr&chl=5&choe=UTF-8"
open(@imageURL) do |chart|
File.open('chart.png', 'wb') {|f| f.write chart.read }
end
UserMailer.welcome_email(@imageURL, @mailID).deliver
end
その画像をwelcome_emailメソッドに渡してメールに添付するにはどうすればよいですか? これを解決するために助けが必要ですか?
user_mailer.rb
def welcome_email(imageURL, mailID)
mail(:to => mailID,
:subject => "code",
:body => "Code for the branch "+imageURL+"")
end
end