Skip to content

add current_user to importer.rb #203

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/active_admin_import/dsl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ def active_admin_import(options = {}, &block)
@importer = Importer.new(
options[:resource_class],
@active_admin_import_model,
options
options,
current_user: current_user
)
begin
result = @importer.import
Expand Down
5 changes: 3 additions & 2 deletions lib/active_admin_import/importer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
require 'csv'
module ActiveAdminImport
class Importer
attr_reader :resource, :options, :result, :model
attr_reader :resource, :options, :result, :model, :current_user
attr_accessor :csv_lines, :headers

OPTIONS = [
Expand All @@ -21,10 +21,11 @@ class Importer
:csv_options
].freeze

def initialize(resource, model, options)
def initialize(resource, model, options, current_user: nil)
@resource = resource
@model = model
@headers = model.respond_to?(:csv_headers) ? model.csv_headers : []
@current_user = current_user
assign_options(options)
end

Expand Down