Sha256: 423a30f8df087e16eaf70d06e1c4fea7a537ff833448631becae43b5bcfb28e6

Contents?: true

Size: 1.54 KB

Versions: 2

Compression:

Stored size: 1.54 KB

Contents

require 'active_admin'
require 'active_admin/axlsx/autoload_extension'
require 'active_admin/axlsx/build_download_format_links'
require 'active_admin/axlsx/version'
require 'active_admin/axlsx/builder'
require 'active_admin/axlsx/dsl'
require 'active_admin/axlsx/resource_extension'
require 'active_admin/axlsx/resource_controller_extension'
class Railtie < ::Rails::Railtie
  config.after_initialize do
    begin
      if Mime::Type.lookup_by_extension(:xlsx).nil?
        # The mime type to be used in respond_to |format| style web-services in rails
        Mime::Type.register "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", :xlsx
      end
    rescue NameError
      puts "Mime module not defined. Skipping registration of xlsx"
    end
    ActiveAdmin.send :include, ActiveAdmin::Axlsx::AutoloadExtension
    ActiveAdmin::ResourceDSL.send :include, ActiveAdmin::Axlsx::DSL
    ActiveAdmin::Resource.send :include, ActiveAdmin::Axlsx::ResourceExtension
    ActiveAdmin::ResourceController.send :include, ActiveAdmin::Axlsx::ResourceControllerExtension
    # TODO remove < 0.5.1 block once active admin has released.
    # Pull request to fix build download format links has already been merged into active admin.
    if ActiveAdmin::VERSION < '0.5.1'
      ActiveAdmin::Views::PaginatedCollection.send :include, ActiveAdmin::Axlsx::BuildDownloadFormatLinks
      ActiveAdmin::Views::Pages::Index.send :include, ActiveAdmin::Axlsx::BuildDownloadFormatLinks
    else
      ActiveAdmin::Views::PaginatedCollection.add_format :xlsx
    end
  end
end


Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
activeadmin-axlsx-1.0.0 lib/active_admin/axlsx.rb
activeadmin-axlsx-1.0.0a lib/active_admin/axlsx.rb