Skip to content
Open
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ Options are common to both the Rake task and the console, except where noted.

`import`: If `true`, output will be in the format needed by the [activerecord-import](https://github.com/zdennis/activerecord-import) gem, rather than the default format. Default: `false`.

`import_options`: Options hash that will be passed to the activerecord-import gem (e.g. `{validate: false}`). Default: `{}`.

`limit`: Dump no more than this amount of data. Default: no limit. Rake task only. In the console just pass in an ActiveRecord::Relation with the appropriate limit (e.g. `SeedDump.dump(User.limit(5))`).

`model[s]`: Restrict the dump to the specified comma-separated list of models. Default: all models. If you are using a Rails engine you can dump a specific model by passing "EngineName::ModelName". Rake task only. Example: `rake db:seed:dump MODELS="User, Position, Function"`
8 changes: 7 additions & 1 deletion lib/seed_dump/dump_methods.rb
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,13 @@ def write_records_to_io(records, io, options)
io.write(",\n ") unless last_batch
end

io.write("\n])\n")
io.write("\n]")

if options[:import] && options[:import_options].present?
io.write(", #{options[:import_options]}")
end

io.write(")\n")

if options[:file].present?
nil
Expand Down