Im going to go a different way then I had hoped with an http get request:
I'm just gonna do the system command line call to generate the pdf, and have
it dump its output as an attachment:

class ReportMailer < ActionMailer::Base
    def daily_shift_report(recipients)
        equipment = Zone.all_equipment

         day_params = "-paramPZONEID='#{equipment['ids'].join(}'
-paramPZONENAME='All Equipment' -paramPDAYSTART='#{360}'
-paramPSEARCHDATE='#{(Time.today - 1).strftime("%m/%d/%Y")}'
-paramPENDDATE='#{(Time.today - 1).strftime("%m/%d/%Y")}'
-paramPDAYEND='#{1080}' -paramPCOMPANYID='0'"

          day_shift =  `sudo -u apache -H /usr/local/reportman/printreptopdf
#{day_params}
#{RAILS_ROOT}/reports/linux/daily_range_badge_activity_by_company.rep 2>>
#{RAILS_ROOT}/stderr.txt`

          recipients users.map{|u| u.email}
          subject "Shift Reports for #{(Time.now - 1).strftime("%A")}"
          from "someplace.net"

          attachment "application/pdf" do |a|
               a.body day_shift
               a.filename = "DayShift-#{(Time.now - 1).strftime("%A")}.pdf"
          end
end

where day_shift is the pdf binary. And that works like a charm! Too bad http
couldn't get me there :(

Thanks for all your suggestions guys!

- Adam
On Feb 4, 2008 2:59 PM, John Bresnik <[EMAIL PROTECTED]> wrote:

>
> > But I figured
> > using ActionController I can send a simple HTTP get request and get
> > information back in response, but oh well :)
>
> yea send_data doesn't quite work the way you think it would.. i.e. it
> doesn't return a byte stream from the method call - instead its turns
> off on the headers and does a simple render [I'm no expert tho] which
> of course has a similar effect. I'd say you'd need to buffer the
> output somewhere [either in memory on the drive depending on the size]
> and then redirect it as the attachment input.. ?
>
> >
>

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

Reply via email to