Skip to content

Instantly share code, notes, and snippets.

@rails-hub
Created May 18, 2015 07:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rails-hub/9762242f124a5842bb30 to your computer and use it in GitHub Desktop.
Save rails-hub/9762242f124a5842bb30 to your computer and use it in GitHub Desktop.
class Accounts::ImportsController < Accounts::BaseController
before_filter :load_import, only: [:show, :update, :perform]
respond_to :html, :json
layout false
expose(:upload_members_form)
def create
import = Import.create(import_params)
render :json => import
end
def update
@import.update_attributes(import_params)
head(200)
end
def perform
@import.enqueue_for_processing
head(200)
end
private
def load_import
@import ||= Import.find(import_params[:id])
end
def import_params
params.require(:import).permit(:id,
:importable_type,
:importable_id,
import_file_attributes: [:id,
:remote_asset_url,
:_destroy],
:column_map => [:email,
:first_name,
:last_name,
:role,
:tags]
)
end
def map_params
params.require(:column_map).permit(:email, :first_name, :last_name, :role, :tags)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment