From 88dfc463a19d62790bb43fbf51493425ac062a8b Mon Sep 17 00:00:00 2001 From: evazion Date: Wed, 10 Jun 2020 22:26:59 -0500 Subject: [PATCH] db/seeds: fix deprecation warning in `find_or_create_by!`. `User.find_or_create_by!` calls `User.name_matches` during username validation, which triggers a deprecation warning for some reason: DEPRECATION WARNING: Class level methods will no longer inherit scoping from `create!` in Rails 6.1. To continue using the scoped relation, pass it into the block directly. To instead access the full set of models, as Rails 6.1 will, use `User.default_scoped`. --- db/seeds.rb | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/db/seeds.rb b/db/seeds.rb index 2c210facd..29589087c 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -1,10 +1,7 @@ require "securerandom" -system = User.find_or_create_by!(name: Danbooru.config.system_user) do |user| - user.password = SecureRandom.base64(32) -end - -unless system.is_moderator? - system.level = User::Levels::MODERATOR - system.save -end +User.create( + name: Danbooru.config.system_user, + password: SecureRandom.base64(32), + level: User::Levels::MODERATOR +)