Posts

Showing posts with the label Methods

๐Ÿš€ 25 Unique Ruby on Rails Methods You Need to Know! ✨

Image
  ๐Ÿš€ 25 Unique Ruby on Rails Methods You Need to Know! ✨ Ruby on Rails is renowned for its elegance and simplicity, providing developers with powerful tools and methods to build applications quickly and efficiently. While some methods are commonly known, Rails also packs a bunch of unique and lesser-known gems that can save you hours of work! Let’s dive into 25 unique Ruby on Rails methods every developer should know, complete with explanations and examples. ๐Ÿ› ️ 1. present? and blank?  ๐Ÿค” Determine if an object is present or empty. These are much smarter than nil? and work for strings, arrays, hashes, and more. name = "Ruby on Rails" puts name.present? # true puts "" .blank? # true 2. squish  ๐Ÿงน Removes all leading, trailing, and excessive inner whitespace from a string. Perfect for cleaning up messy input! messy_string = " Too much space! " puts messy_string.squish # "Too much space!" 3. pluck  ๐ŸŒฑ Fetch specific fields directly fro...