Skip to content

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
4 changes: 3 additions & 1 deletion lib/active_admin_import/dsl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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) || {})

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.

@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]

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?


# go back to form
return render template: options[:template] unless @active_admin_import_model.valid?
@importer = Importer.new(
Expand Down