FasterCSV

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)

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

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

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