My rails 3 app on heroku receives incoming emails. I want to be able to accept attachments, but I cannot get rails to handle attachments without errors.
It would be ideal to pass the attachment provided by ActionMailer.
message_all = Mail.new(params[:message])
message_all.attachments.each do |a|
attachments.each do |a|
.attachments.build(
:attachment => a
)
end
end
These are errors with: NoMethodError (undefined methodrewinding for #) `Where attachments are a model, with attachments are a clip
Ideas y? Is there any other way to pass the attachment = a, bond?
I tried a different approach by creating tempfile:
tempfile = File.new("#{Rails.root.to_s}/tmp/#{a.filename}", "w+")
tempfile << a.body
tempfile.puts
attachments.build(
:attachment => File.open(tempfile.path) )
The problem with tempfile is that files without the blah extension instead of blah.png break the clip, so I want to avoid a temporary file. and by creating Identity errors, imagemagick does not know what they do not have.
Thank you so much for any advice on this.