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

Many to many relationships #66

Open
CV-Gate opened this issue Aug 20, 2015 · 3 comments
Open

Many to many relationships #66

CV-Gate opened this issue Aug 20, 2015 · 3 comments
Labels

Comments

@CV-Gate
Copy link

CV-Gate commented Aug 20, 2015

Is there any way to import a has_many or has_and_belongs_to_many relationship? A collection of ids? I can't figure out how to build the csv also.

Thanks for this great gem.

@Fivell
Copy link
Member

Fivell commented Aug 21, 2015

@CV-Gate , I was never used this in such case, do you have any real-live example and suggestions how it should work?

@CV-Gate
Copy link
Author

CV-Gate commented Sep 9, 2015

Sorry for coming back so late, I didn't get the notification.
When I had to deal with this in the past I have done it in two different ways:

  • If using the primary key in the import, I repeated the line of the model instance as many times as necessary to include the relationships, leaving blank other fields.
  • Other approach was to separate with pipes "|" the related entities into the same field. Just like an array.

Regards.

@Fivell
Copy link
Member

Fivell commented Sep 9, 2015

@CV-Gate, can you give an example with couple of csv lines and ActiveRecord models?

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

No branches or pull requests

2 participants