Skip to content
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

Is it possible to add nested resource id on the fly? #83

Closed
lifecoderua opened this issue Dec 25, 2015 · 3 comments
Closed

Is it possible to add nested resource id on the fly? #83

lifecoderua opened this issue Dec 25, 2015 · 3 comments

Comments

@lifecoderua
Copy link

I have a nested resource, like /libraries/15/commits and want to import commits from css.

Is it possible to get the parent resource id and add it on the fly?

I could see the parent id in the Better Errors' dump as a Request parameters > library_id but can't figure how to catch it.

Thank you in advance.

@Fivell
Copy link
Member

Fivell commented Dec 26, 2015

@lifecoderua , you can override template and add hidden input with library_id to make it model attribute https://github.com/activeadmin-plugins/active_admin_import/blob/master/lib/active_admin_import/model.rb#L31
Template should be passed as option when declaring active_admin_import for your resource

@Fivell
Copy link
Member

Fivell commented Mar 4, 2016

Sort of this is possible

before_filter only: [:do_import] do
    Thread.current['import.library_id'] =  params['library_id']
  end
  active_admin_import before_batch_import: ->(importer) do 
         importer.headers["library_id"] = :library_id
         importer.batch_replace(:library_id, { nil =>  Thread.current['import.library_id']} )
   end

@kxu1988
Copy link

kxu1988 commented Oct 9, 2018

"before_filter" should change to "before_action" in Rails5.2

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

No branches or pull requests

3 participants