-
Notifications
You must be signed in to change notification settings - Fork 617
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
Add Examples to Readme #229
Comments
agreed; it isn't clear how we are supposed to implement an import with more than one associated model |
The wiki has some examples including one that imports an associated model. I believe the |
yes i added a 'multi-tier' example to the wiki last week and neglected to update this issues thread. thanks. i discuss it in issue #231 |
@allenwlee what might the 'multi-tier' example syntax be if both |
@JHFirestarter is if i understand your question correctly, an example would be as follows:
|
@allenwlee correct re: just a column. Apologies, on "line 3" you have the book attributes ( |
yes that is intentional. line three instantiates a |
Thx. I'll update my question to match the attributes you have in the example. |
@allenwlee Btw, +1 for @triptec 's OP. I think (maybe wrong) a good example would be a gist with models and similar example .rb using books, publishers & reviews, where there's need for a bulk action with associations in an app that relies on those associations in its views. Instead of values like "John Smith," one would have to work with a variable of some sort before import. If source data is commonly in some type of excel file, would the best example include converting that to an array of arrays (or array of hashes)? How does one refactor for an array of arrays (or array of hashes) instead of "John Smith?" The reason for the question is reading other issues, it seems there's no solid example that includes the things you found (like the need for Here's my attempt, which fails to accomplish the goal, as (while it does import to 3 tables quickly) it does not populate the foreign keys
It seems that perhaps the reviews and publishers importing above may be redundant (and counterproductive) if associations are setup well and .build is used--but I do not know how to extrapolate from your example. I'm sure there's a much better way than I'm attempting...but after days (weeks) on stack overflow and reading ar-import lib/ etc, I would think this kind of example is very common and useful to others if done correctly. Simply adding |
OK, i don't know what the association is between books and publishers. unless it is Book e.g.:
|
@allenwlee True (was trying to keep with README). Better example would be critics instead of publishers. Both Books and Critics would each have |
Update: tried importing Critics a few ways to no avail (e.g.
starts to create books in one big motion, but then it yields |
I think we can go ahead and close this issue. |
It would be nice with some code to go with the example of books, publishers and reviews in the readme.
The text was updated successfully, but these errors were encountered: