Skip to content

Conversation

ricardojudo
Copy link
Contributor

…e active admin page has the 'belongs_to' statement.

I needed to implement this change in order to get a reference of the parent resource within a proc passed to the before_batch_import option in order to insert additional information to each line.

before_batch_import: Proc.new{|importer|         
      _form = importer.model.parent
       importer.csv_lines.each do |line|
         line.push _form.id
         line.push _form.generate_registration_code
       end
 }

I was not sure where and how to document this change.

What do you think about this proposal?

…e active admin page has the 'belongs_to' statement.
@active_admin_import_model = options[:template_object]
@active_admin_import_model.assign_attributes(params[params_key].try(:deep_symbolize_keys) || {})
@active_admin_import_model.assign_attributes(params[params_key].try(:deep_symbolize_keys) || {})
@active_admin_import_model.assign_attributes(parent: parent) unless defined?(parent).nil?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line is too long. [97/80]

params = ActiveSupport::HashWithIndifferentAccess.new _params
@active_admin_import_model = options[:template_object]
@active_admin_import_model.assign_attributes(params[params_key].try(:deep_symbolize_keys) || {})
@active_admin_import_model.assign_attributes(params[params_key].try(:deep_symbolize_keys) || {})

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line is too long. [112/80]
Trailing whitespace detected.

@coveralls
Copy link

coveralls commented Apr 12, 2017

Coverage Status

Coverage decreased (-0.8%) to 96.942% when pulling 7afc6e6 on ricardojudo:master into 30b6d71 on activeadmin-plugins:master.

@Fivell
Copy link
Member

Fivell commented Apr 18, 2017

@ricardojudo , for new features to merge there is a requirement to add spec here https://github.com/activeadmin-plugins/active_admin_import/blob/master/spec/import_spec.rb

@active_admin_import_model = options[:template_object]
@active_admin_import_model.assign_attributes(params[params_key].try(:deep_symbolize_keys) || {})
@active_admin_import_model.assign_attributes(params[params_key].try(:deep_symbolize_keys) || {})
@active_admin_import_model.assign_attributes(parent: parent) unless defined?(parent).nil?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ricardojudo , why not
if parent? instead of defined?(parent).nil?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants