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...

Casey

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to