How to automatically generate a password if it is not provided using authlogic

I am new to this site and to rubies! I have a general authlogic installation and require a password to be automatically generated for user registration if the user has not set a password. What is the best way to do this?

+3
source share
1 answer

Decision:

#app/models/User.rb
class User < ActiveRecord::Base
#...
  before_validation_on_create { |record| record.randomize_password unless record.password }
#...
end
+3
source

Source: https://habr.com/ru/post/1739271/


All Articles