On Tue, 2009-07-28 at 07:39 -0700, Craig White wrote:
> On Tue, 2009-07-28 at 10:21 -0400, Casey Ellett wrote:
> >
> >
> > On Tue, Jul 28, 2009 at 10:07 AM, Craig White <[email protected]>
> > wrote:
> >
> > have problem with getting output. I get an error no matter how
> > I try to
> > get output...
> >
> > NoMethodError in Reports#commissions_export
> >
> > Showing app/views/reports/commissions_export.erb where line
> > #26 raised:
> >
> > undefined method `send_data' for
> > #<ActionView::Base:0xb717a2c0>
> >
> > This is all I have in commissions_export.erb
> >
> > <%= csv_string = FasterCSV.generate do |csv|
> > csv << [ 'Commission Report' ]
> > csv << [ 'Reporting Period Starts', '', '', '',
> > @period.lastdate_in_period.strftime("%m-%d-%Y") ]
> > csv << [ ]
> > csv << [ "Customer (Branch)",
> > "Invoice #",
> > "Stock ID",
> > "Qty.",
> > "Sale Price",
> > "Cost",
> > "Gross Profit",
> > "Commission"
> > ]
> > @sales.each do |sale|
> > csv << [ sale.custbranch,
> > sale.transno,
> > sale.stockid,
> > sale.qty,
> > sale.amt.to_fl(2),
> > sale.cost.to_fl(2),
> > (sale.amt - sale.cost).to_fl(2),
> > ((sale.amt - sale.cost) *
> > @salesman.commissionrate1).to_fl(2)
> > ]
> > end
> > end
> > send_data csv_string, :type => "text/plain",
> > :filename=>@salesman.salesmanname + "_Commissions.csv",
> > :disposition => 'attachment'
> > %>
> >
> > (send_data stuff is from examples which don't seem to work)
> >
> >
> > --
> > This message has been scanned for viruses and
> > dangerous content by MailScanner, and is
> > believed to be clean.
> >
> >
> >
> >
> > Craig,
> >
> > I am using the format below for a .csv export:
> >
> > send_data(csv,
> > :type => 'text/csv; charset=utf-8; header=present',
> > :filename => filename)
> >
> > A variation of the above may help.
> >
> > I remember banging my head against the wall trying to get this to
> > work...
> ----
> I still get the same error...do you think that this is caused because
> this is code inside a view? If I put this code in my controller, then I
> get an error because it wants a view file, even if I add
> 'render :layout => false'
>
> this makes me crazy because I had all of this kind of stuff working in
> 1.2.x and now have to resort to other things in 2.3.2 and dealing with
> all sorts of new errors.
----
that was it...I had to move it all back into the controller and et
voila...
Thanks - by the way, I found this to be more useful...
:type => 'application/vnd.ms-excel; charset=utf-8;
header=present',
Craig
--
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---