[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.


Disable validation

Just add (validations: false) next to has_secure_password.


class Post < ApplicationRecord
  has_secure_password(validations: false)


You can now post blank posts by disabling validation.