Ruby Infinity: How It Works & Why It Matters

What is infinity in Ruby? It’s something that has a starting point but no ending. In Ruby, we can express this concept of infinity with the Float::INFINITY constant. You may be wondering how this is useful. Let me explain with examples! Infinity As A Result Of Arithmetic Operations Ruby returns an Infinity object, as the … Read more

How to Use The Rails Where Method (With Examples)

In Rails, you can query the database through your models to access your data. You can do this using ActiveRecord methods. Like where, find, or find_by. As a result you get: With find_by, a single record or nil With where, an ActiveRecord::Relation object With find, a single record, found by its primary column (usually id), … Read more

3 Awesome Ways To Use Ruby’s Gsub Method

Let’s talk about Ruby’s gsub method & how to use it. First, you’ll need a string to play with this method. Why? Because the whole point of gsub is to replace parts of a string. In fact: The “sub” in “gsub” stands for “substitute”, and the “g” stands for “global”. Here is an example string: … Read more