Sha256: 789b9ccbc08c3f08f6d56acaf124883c719dfa9e406e7c2b909c92448e8df6ff

Contents?: true

Size: 718 Bytes

Versions: 3

Compression:

Stored size: 718 Bytes

Contents

class ImportController < ApplicationController
  map_fields :create, ['Title', 'First name', 'Last name', 'Email'], :file_field => 'file', :params => [:name]

  def new
    render
  end

  def create
    begin
      if fields_mapped?
        #Process import
        
        render :done
      else
        render 
      end
    rescue MapFields::InconsistentStateError
      logger.debug 'catching InconsistentStateError'
      redirect_to :action => :new, :status => 303
      return
    rescue MapFields::MissingFileContentsError
      logger.debug 'catching MissingFileContentsError'
      flash[:error] = 'Please upload a file'
      render :action => :new
      return
    end

    logger.debug 'here'
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
map_fields-1.0.3 spec/rails_root/app/controllers/import_controller.rb
map_fields-1.0.2 spec/rails_root/app/controllers/import_controller.rb
map_fields-1.0.1 spec/rails_root/app/controllers/import_controller.rb