Ruby on rails 如何将额外参数传递到\u csv方法

Ruby on rails 如何将额外参数传递到\u csv方法,ruby-on-rails,ruby-on-rails-3,Ruby On Rails,Ruby On Rails 3,控制器 format.csv { send_data @find_customer.to_csv, :filename => "customer" + ".csv" } format.xls { send_data @find_customer.to_csv(col_sep: "\t"), filename: 'customer.xls'} 型号 def self.to_csv(options = {}) CSV.generate(options) do |csv|

控制器

format.csv { send_data @find_customer.to_csv, :filename => "customer" + ".csv" }
format.xls { send_data @find_customer.to_csv(col_sep: "\t"), filename: 'customer.xls'}
型号

  def self.to_csv(options = {})
    CSV.generate(options) do |csv|
      csv << ["SHW#", "LeadId", "Fullname", "Address", "City", "State", "Zip", "Phone", "Email", "Created-At"]
      all.each do |customer|
        csv << [customer.id, customer.leadid, "#{customer.first_name} #{customer.last_name}", customer.customer_address, customer.customer_city, customer.customer_state, customer.customer_zip, customer.customer_phone, customer.email, customer.created_at.strftime("%m/%d/%Y")] 
      end
    end
  end
def self.to_csv(选项={})
CSV.生成(选项)do | CSV|
csv试试这个:

format.csv { send_data @find_customer.to_csv({}, '2014-05-08', '2014-05-10'), :filename => "customer" + ".csv" }
模型

def self.to_csv(选项={},开始日期='',结束日期='')
CSV.生成(选项)do | CSV|

那有什么问题?将该参数放入第5行的数组中。给我一个例子,self.to_csv(options={}),这里我想从控制器获取值
def self.to_csv(options = {}, start_date = '', end_date = '')
  CSV.generate(options) do |csv|
    csv << ["SHW#", "LeadId", "Fullname", "Address", "City", "State", "Zip", "Phone", "Email", "Created-At", "Start", "End"]
    all.each do |customer|
      csv << [customer.id, customer.leadid, "#{customer.first_name} #{customer.last_name}", customer.customer_address, customer.customer_city, customer.customer_state, customer.customer_zip, customer.customer_phone, customer.email, customer.created_at.strftime("%m/%d/%Y"), start_date, end_date] 
    end
  end
end