lib/seed_box.rb in seed_box-0.2.0 vs lib/seed_box.rb in seed_box-0.2.1
- old
+ new
@@ -12,14 +12,12 @@
handle_errors(record, find_or_create_by, update_with)
end
def seed_once(model, find_or_create_by, create_with = {})
- record = model.where(find_or_create_by).first_or_initialize(create_with)
+ return if model.where(find_or_create_by).exists?
- record.save
-
- handle_errors(record, find_or_create_by, create_with)
+ seed(model, find_or_create_by, create_with)
end
def seed_file(name)
File.new(Rails.root.join('db/seeds').join(name))
end