Created
May 18, 2015 07:48
-
-
Save rails-hub/9762242f124a5842bb30 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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