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

Returns information should be in the readme #174

Closed
globalkeith opened this issue Jan 29, 2015 · 6 comments
Closed

Returns information should be in the readme #174

globalkeith opened this issue Jan 29, 2015 · 6 comments
Labels

Comments

@globalkeith
Copy link

globalkeith commented Jan 29, 2015

Hey, great gem.

Just wanted to suggest that the returns stuff is added to the readme/examples.

I was just about to fork to implement this functionality but I see its already been done, just not mentioned in the help file.

thanks

@jkowens jkowens added the docs label Oct 8, 2016
@jkowens jkowens mentioned this issue Apr 4, 2017
10 tasks
@p-becker
Copy link

p-becker commented Jun 2, 2018

I just added a small Paragraph at the bottom of this Wiki page: https://github.com/zdennis/activerecord-import/wiki/Supported-Database-Adapters

Was this the right thing to do? And does this sufficiently document the methods?

@dillonwelch
Copy link
Contributor

@jkowens I'm a little confused on what this one is asking for? Do you have a little more guidance on what needs to be added/copied over into the README file?

@jkowens
Copy link
Collaborator

jkowens commented Oct 13, 2018

The link above was outdated, here is the return object that I believe this was referring to:

Result = Struct.new(:failed_instances, :num_inserts, :ids, :results)

# This returns an object which responds to +failed_instances+ and +num_inserts+.

@dillonwelch
Copy link
Contributor

It seems like the best way would be to just update that one line to directly reference that Result object something like returns a Result. I'm not super duper familiar with Ruby documentation on how to make that automagically link up to that line, do you have an idea on how to do that or is it off to Google we go?

@dillonwelch
Copy link
Contributor

Thoughts @jkowens ?

@jkowens
Copy link
Collaborator

jkowens commented Nov 15, 2018

Maybe we could just display sample return objects in the examples:

articles = [
  Article.new(author_id: 1, title: 'First Article', content: 'This is the first article'), 
  Article.new(author_id: 2, title: 'Second Article', content: ''),
  Article.new(author_id: 3, content: '')
]
Article.import articles, returning: :title # => #<struct ActiveRecord::Import::Result failed_instances=[#<Article id: 3, author_id: 3, title: nil, content: "", created_at: nil, updated_at: nil>], num_inserts=1, ids=["1", "2"], results=["First Article", "Second Article"]>

The ids and results attributes will only be useful for those using Postgres. They will just be empty arrays for MySQL and SQLite.

dillonwelch added a commit to dillonwelch/activerecord-import that referenced this issue Nov 19, 2018
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

4 participants