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

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.

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.

Recommended Posts

[Bcrypt] how to cancel presence: true of has_secure_password
How to use setDefaultCloseOperation () of JFrame
How to name variables 7 selections of discomfort
[java] Summary of how to handle char
Summary of how to write annotation arguments
How to determine the number of parallels
[Java] [Maven3] Summary of how to use Maven3
How to sort the List of SelectItem
Summary of how to select elements in Selenium
JDBC promises and examples of how to write
How to find the cause of the Ruby error
[java] Summary of how to handle character strings
[Rails] Introduction of pry-rails ~ How to debug binding.pry
Summary of how to create JSF self-made tags
Customize how to divide the contents of Recyclerview
[Java] Summary of how to abbreviate lambda expressions
How to get today's day of the week
Output of how to use the slice method
How to use enum (introduction of Japanese notation)
[Swift UI] How to disable ScrollsToTop of ScrollView
How to use JQuery in js.erb of Rails6
How to display the result of form input
[For super beginners] How to use autofocus: true
[Java] How to get the authority of the folder
How to specify index of JavaScript for statement
How to deploy
[Java] How to get the URL of the transition source
[Java] How to use compareTo method of Date class
How to delete / update the list field of OneToMany
How to apply HandlerInterceptor to http inbound-gateway of Spring Integration
[Java] Types of comments and how to write them
[Rails, JS] How to implement asynchronous display of comments
[Ruby] How to find the sum of each digit
How to install the root certificate of Centos7 (Cybertrust)
[Java] How to get the maximum value of HashMap
[Rails] How to change the column name of the table
[SwiftUI] How to specify the abbreviated position of Text
As of April 2018 How to get Java 8 on Mac
How to set BuildConfig of library project (module) to Debug
How to use CommandLineRunner in Spring Batch of Spring Boot
Summary of Java communication API (1) How to use Socket
[Android] How to get the setting language of the terminal
Summary of Java communication API (3) How to use SocketChannel
How to prevent editTextPreference of android PreferenceFragmentCompat from breaking
Summary of Java communication API (2) How to use HttpUrlConnection
[Rails] How to get the contents of strong parameters
How to judge the click of any area of the image
How to boot by environment with Spring Boot of Maven
Summary of how to implement default arguments in Java
How to download the old version of Apache Tomcat
[Swift] How to get the document ID of Firebase
How to execute WebCamCapture sample of NyARToolkit for Java