Module: ActiveScaffold::Actions::Export
- Defined in:
- lib/active_scaffold/actions/export.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#export ⇒ Object
if invoked directly, will use default configuration.
-
#show_export ⇒ Object
display the customization form or skip directly to export.
Class Method Details
.included(base) ⇒ Object
3 4 5 6 |
# File 'lib/active_scaffold/actions/export.rb', line 3 def self.included(base) base.before_action :export_authorized?, :only => [:export] base.before_action :show_export_authorized?, :only => [:show_export] end |
Instance Method Details
#export ⇒ Object
if invoked directly, will use default configuration
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/active_scaffold/actions/export.rb', line 22 def export export_config = active_scaffold_config.export if params[:export_columns].nil? export_columns = {} export_config.columns.each { |col| export_columns[col.to_sym] = 1 } = { :export_columns => export_columns, :full_download => export_config.default_full_download.to_s, :delimiter => export_config.default_delimiter, :skip_header => export_config.default_skip_header.to_s } params.merge!() end set_includes_for_columns(:export) @export_config = export_config # Make sure active_scaffold's find_page is dealing with the same list of # columns. Prevents an invalid SQL query when exporting after filtering # with field_search against a relation column, and that relation column is # not included in the set of export columns. @list_columns = @export_columns # this is required if you want this to work with IE if request.env['HTTP_USER_AGENT'] =~ /msie/i response.headers['Pragma'] = "public" response.headers['Cache-Control'] = "no-cache, must-revalidate, post-check=0, pre-check=0" response.headers['Expires'] = "0" end response.headers['Content-Disposition'] = "attachment; filename=#{export_file_name}" respond_to_action(:export) end |
#show_export ⇒ Object
display the customization form or skip directly to export
9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/active_scaffold/actions/export.rb', line 9 def show_export @export_config = active_scaffold_config.export respond_to do |wants| wants.html do render(:partial => 'show_export', :layout => true) end wants.js do render(:partial => 'show_export', :layout => false) end end end |