Sha256: 33cce30edbb58edb690f3de7bb9f43a1dacc826f45cb205babb18f55efe08d5d
Contents?: true
Size: 1.19 KB
Versions: 1
Compression:
Stored size: 1.19 KB
Contents
module RailsImporter class ImportsController < RailsImporter.parent_controller_class before_filter :set_importer_class def new @import = Import.new(importer_key: @importer_class.key) end def create @import = Import.new(import_params) if @import.valid? ImportJob.perform_later @import.importer_key, @import.filepath flash[:notice] = I18n.t(:processing_import, scope: :rails_importer) redirect_to after_import_path else render 'new' end end def sample file = File.open(@importer_class.sample_file) send_data file.read, :filename => File.basename(@importer_class.sample_file) rescue => e flash[:alert] = I18n.t(:sample_file_not_available, scope: :rails_importer) redirect_to after_import_path end private def set_importer_class @importer_class = RailsImporter.importer_class(params[:importer_key].to_s) if @importer_class.nil? flash[:error] = I18n.t(:importer_does_not_exist, scope: :rails_importer) redirect_to after_import_path end end def import_params params.require(:import).permit(:importer_key, :import_file) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rails_importer-0.2.1 | app/controllers/rails_importer/imports_controller.rb |