update_or_create allows update_or_create to ActiveRecord. And allows db:seed extension to Rake. Very useful when use seeds.rb.
- Add
gem 'update_or_delete_or_create'
to Gemfile.
- add
require 'update_or_create'
to seeds.rb. - Model.update_or_create([id: 1, value: 'test'], or etc...])
- When set
{ id: 4, 'delete record !!!' => true },
then record of "id=4" will be deleted. - Make db/seeds/ext.rb(or etc) are same grammer as seeds.rb,
then you can extra seed file as
rake db:seed:ext
command.
- Ruby 2.0 or later.
- RoR 4.1 or later.
Copyright © 2014 Jun’ya Shimoda(JironBach)
Dual licensed under the MIT license and GPL license.