[Ruby] [Bcrypt] how to cancel presence: true of has_secure_password

less than 1 minute read

I’m using bcrpt, but I want to set a password arbitrarily

I made it possible to set a password for posts with bcrpt,
By default, empty posts are set to be played, so
I will show you how to cancel it.

  • The method for setting a password for posting is introduced below.

    https://qiita.com/hiruhiru/items/9dffc729f5192df243a8

Disable validation

Just add (validations: false) next to has_secure_password.

qiita.rb


class Post < ApplicationRecord
  has_secure_password(validations: false)
end

Summary

You can now post blank posts by disabling validation.