it was due to the version of rolify. It's been fixed with 3.2 for me cf
Deprecation warning when using `rake db:seed`
-
26-06-2022 - |
题
I'm having a DEPRECATION WARNING
when using rake db:seed
This dynamic method is deprecated.
This happens on user.add_role :admin
of the block below:
user = User.find_or_create_by(email: ENV['ADMIN_EMAIL'].dup) do |u|
u.password = ENV['ADMIN_PASSWORD'].dup
u.password_confirmation = ENV['ADMIN_PASSWORD'].dup
end
puts 'user: ' << user.email
user.add_role :admin
user.skip_confirmation!
user.save!
I have already cleaned the code for a find_or_create_by_email
warning, but I cannot find the answer for the add_role
.
解决方案
不隶属于 StackOverflow