Thursday 16 November 2017

ActiveAdmin custom csv file method


collection_action :csv_isp_report, method: :get do
      @data = []
      @isp_manuall = $record_arr
      @isp_manuall.map{|isp_manuall| isp_manuall.map { |isp| @data << isp}}
      @data_records = @data
      csv_string = CSV.generate do |csv|
        csv << IspReport.attribute_names
        @data_records.each do |ispr|
          csv << ispr.attributes.values
        end
      end
      send_data csv_string 
  end

in View

= link_to "CSV", csv_isp_report_admin_isp_reports_path(format: "csv")

No comments:

Post a Comment

Revert last commit or second last and more....

 Git revert commit_id -m 1 this command willl revert last commit  Git revert commit_id -m 2 this command will revert second commit with same...