1, install:
gem install ruport -y
gem install ruport-util -y
2, require
在 environment.rb 中,写入: require "ruport"
3, Loading acts_as_reportable
在model中: 例如
[quote]class Report < ActiveRecord::Base
acts_as_reportable
end[/quote]
4, code
在controller中:
[quote]def index
table = Report.report_table(:all,
:only => %w[host_os rubygems_version user_key],
:conditions => "user_key is not null and user_key <> ''")
send_data table.to_csv,
:type => "application/csv",
:disposition => "inline",
:filename => "report.csv"
end[/quote]
end
gem install ruport -y
gem install ruport-util -y
2, require
在 environment.rb 中,写入: require "ruport"
3, Loading acts_as_reportable
在model中: 例如
[quote]class Report < ActiveRecord::Base
acts_as_reportable
end[/quote]
4, code
在controller中:
[quote]def index
table = Report.report_table(:all,
:only => %w[host_os rubygems_version user_key],
:conditions => "user_key is not null and user_key <> ''")
send_data table.to_csv,
:type => "application/csv",
:disposition => "inline",
:filename => "report.csv"
end[/quote]
end