Member-only story
Active Support is the feature of Ruby on Rails which is responsible for providing utilities and extensions.
blank?
Returns true if the object in the following state,
false.blank? # truenil.blank? # true[].blank? # true{}.blank? # true"".blank? # true''.blank? # true' '.blank? # true
Example:
name = '''Guest' if name.blank? # Guest
present?
Returns the true/false value. present? internally reuses the blank?. An object is present if it’s not blank.
name = 'Gokul'name if name.present? # Gokul
presence
Returns the object/nil. The presence
helps to get the value if the value present else will returns nil. It’s a good alternative to the conditional statement.
Example
name = ''
puts "Hi #{name.present? ? name : 'Guest'}" # Hi Guestname = 'Gokul'
puts…