Heroku and tmp folder

In my Rails app I have delayed_job gem to delay all the emails, the
problem
with this appear when I want to have some attachments in the emails, in
development I store then in tmp folder.
I Heroku I thought that might be possible as well but I get the error
the
there is no file in that folder.

This is my code inside my controller:

def send_bill
@sale = Sale.find(params[:id])
@client = @sale.client
create_pdf(@sale, @client)
PdfMailer.delay.send_pdf_info(@client, current_user.email)
@bill.update(sent: true)
flash.now.notice = “Bill was sent successfully”
render :show
end

The method create_pdf is the one that create the pdf and store it in the
tmp folder.

def create_pdf(sale, client, is_bill = true)
name = is_bill ? “factura.pdf” : “presupuesto.pdf”
action = is_bill ? “bills/show” : “bills/budget”
@sale = sale
@client = client
@bill = @sale.bills.first if is_bill
file = File.new("#{Rails.root}/tmp/#{name}", “w+”)
kit = PDFKit.new( render_to_string(action: “#{action}”, layout:
‘pdf’,
format: “pdf”), :page_size => ‘A4’)
file = kit.to_file(file.path)
end

Inside my mailer the code is:

def send_pdf_info(client, current_user_email)
@client = client
attachments[“Factura.pdf”] =
File.read(#{Rails.root}/tmp/factura.pdf")

mail(to: default_to(@client.email), bcc: current_user_email, 

subject:
“Factura Printoria”)
end

I’m not able to solve this.
Any help will be really appreciated.

On Wed, Apr 23, 2014 at 7:59 AM, Gustavo C. [email protected]
wrote:

In my Rails app I have delayed_job gem to delay all the emails, the problem
with this appear when I want to have some attachments in the emails, in
development I store then in tmp folder.
I Heroku I thought that might be possible as well but I get the error the
there is no file in that folder.

Heroku does not provide access to a file system.

Look into cloud storage providers, e.g. Amazon S3, Rackspace
Cloud Files, etc.


Hassan S. ------------------------ [email protected]
http://about.me/hassanschroeder
twitter: @hassan

Thanks. I read some more and I’m going to use amazon S3.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs