[Rails] Check the contents of the object

What is an object? Objects are like "boxes". Therefore, when checking for existence,

Let's look at it from the perspective of.

Does the box itself not exist? Nil?

python


obj.nil?

Is the box empty? Empty?

python


obj.empty?

Does the box itself not exist? Is the content empty even if it is done? Blank?

"The box does not exist or the contents do not exist" By the way, ** Rails-only method **

python


obj.blank?

#Synonymous
obj.nil? || obj.empty?

Isn't the box itself existing and empty? Present?

"There is a box and there are contents" By the way, ** Rails-only method **

python


obj.present?

#Synonymous
!obj.nil? && !obj.empty?
obj.blank?

Recommended Posts

[Rails] Check the contents of the object
Check the migration status of rails
Check the contents of the Java certificate store
Check the contents of params with pry
Memo: [Java] Check the contents of the directory
Check the processing contents with [rails] binding.pry
Verify the contents of the argument object with Mockito
The illusion of object orientation
[Rails] How to get the contents of strong parameters
Replace the contents of the Jar file
Check the version of Cent OS
Explanation of the order of rails routes
Delete all the contents of the list page [Ruby on Rails]
[Ruby] Display the contents of variables
Check the root on the Rails browser
[Rails] Read the RSS of the site and return the contents to the front
How to check for the contents of a java fixed-length string
The identity of params [: id] in rails
part of the syntax of ruby ​​on rails
Folding and unfolding the contents of the Recyclerview
Prepare the security check environment for Rails 6
[Ruby] Cut off the contents of twitter-ads
[Rails] Change the label name of f.label
The process of introducing Vuetify to Rails
Format the contents of LocalDate with DateTimeFormatter
Check the version of the standard Web software.
[Java] Check the number of occurrences of characters
The contents of the data saved by CarrierWave.
Check the operation of the interface through threads
The problem that the contents of params are completely displayed in the [Rails] view
[Rails] Check the instance variables and local variables of the file you are browsing
Android development, how to check null in the value of JSON object
[Ruby On Rails] How to search the contents of params using include?
[Order method] Set the order of data in Rails
Check the version of the JDK installed and the version of the JDK enabled
JAVA: jar, aar, view the contents of the file
[Rails] Button to return to the top of the page
Customize how to divide the contents of Recyclerview
[Ruby on Rails] Until the introduction of RSpec
Overwrite the contents of config with Spring-boot + JUnit5
I want to var_dump the contents of the intent
Let's check the feel of Spring Boot + Swagger 2.0
[Ruby] "Reference to object" and "Contents of variable"
How to check Rails commands in the terminal
[Ruby on Rails] How to Japaneseize the error message of Form object (ActiveModel)
A review of the code used by rails beginners
The world of clara-rules (2)
List the contents of categories created with Active Hash
Check the capacity of the Linux server. (Df command, du command)
[Java] Check the JDK version of the built war file
Docker the development environment of Ruby on Rails project
[Rails] Introduction of PAY.JP
Test the contents of an Excel file with JUnit
Judgment of the calendar
The world of clara-rules (4)
I summarized the display format of the JSON response of Rails
The world of clara-rules (1)
Check the behavior of Java Intrinsic Locks with bpftrace
[Rails] How to change the column name of the table
The world of clara-rules (3)
Rails Tutorial/Significance of Indexing