collection_action :download_report, method: :get do users = User.where('created_at >= ?', Date.today - 1.month) csv = CSV.generate( encoding: 'Windows-1251' ) do |csv| # add headers csv << [ #Some header ] # add data users.each do |user| csv << [ user.created_at ] end end # send file to user send_data csv.encode('Windows-1251'), type: 'text/csv; charset=windows-1251; header=present', disposition: "attachment; filename=report.csv" end action_item only: :index do link_to "csv report", download_report_admin_#{models}_path, method: :get end index download_links: false do # off standard download link end