-
Notifications
You must be signed in to change notification settings - Fork 101
Parent resource is made accesible through the template object when th… #137
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
base: master
Are you sure you want to change the base?
Conversation
…e active admin page has the 'belongs_to' statement.
@@ -76,7 +76,9 @@ def active_admin_import(options = {}, &block) | |||
_params = params.respond_to?(:to_unsafe_h) ? params.to_unsafe_h : params | |||
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) || {}) | |||
@active_admin_import_model.assign_attributes(parent: parent) unless defined?(parent).nil? |
There was a problem hiding this comment.
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]
@@ -76,7 +76,9 @@ def active_admin_import(options = {}, &block) | |||
_params = params.respond_to?(:to_unsafe_h) ? params.to_unsafe_h : params | |||
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) || {}) |
There was a problem hiding this comment.
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.
@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 |
@@ -76,7 +76,9 @@ def active_admin_import(options = {}, &block) | |||
_params = params.respond_to?(:to_unsafe_h) ? params.to_unsafe_h : params | |||
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) || {}) | |||
@active_admin_import_model.assign_attributes(parent: parent) unless defined?(parent).nil? |
There was a problem hiding this comment.
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?
…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.
I was not sure where and how to document this change.
What do you think about this proposal?