Hey guys,

I'm setting up ActionMailer for the first time to email pdfs generated on
the fly. I have the following so far:

class ReportMailer < ActionMailer::Base
    def daily_shift_report(recipients, day, report_params)
            recipients recipients.map{|u| u.email}
            subject "Shift Reports for #{day}"
            from "[EMAIL PROTECTED]"

            attachment "application/pdf" do |a|
                a.body = # Some http request to grab the pdf
            end
    end
end


NOTE: this isn't working code yet :)

I need to do a get request on some url (lets call it
"/generate_report?#{report_params}") that will return a pdf using this
method:

     send_data(pdf_file, :type => "application/pdf", :filename =>
"#{pdf_title}.pdf")

which I use in other parts of the site to serve up pdfs, but I wasn't sure
how to make a basic request and grab the response using ActionController.
There is a get method, but that just returns a status (200, 404, etc).

QUESTION: Is there anything like

Net::HTTP.start('localhost', 3000) do |http|
   response = http.get("/generate_report?#{report_params}", 'Accept' =>
'application/pdf')
   a.body =  response.body
end

built into ActionController that I could use to grab the response from a
request? I would think calling app.get should return something more than
just a status... like headers and a response!

Thanks!

--~--~---------~--~----~------------~-------~--~----~
SD Ruby mailing list
sdruby@googlegroups.com
http://groups.google.com/group/sdruby
-~----------~----~----~----~------~----~------~--~---

Reply via email to