All 140+ RubyGuides Articles

7 Great Ruby Gems Most People Haven’t Heard About

What are the best Ruby gems that you can use in your Rails projects? That's what you'll discover in this ...
Read More

Understanding The Ruby Next & Break Keywords

Keywords, like next & break are part of the Ruby programming language, so if you want a complete understanding of ...
Read More

What is Module Autoloading in Ruby?

How do we bring together multiple source code files into one? We require them. This tells Ruby to look for ...
Read More

Why Do We Need Application Servers in Ruby?

You start building your new shiny web application in Ruby. And before you write any code... You want to see ...
Read More

How to Use Logs in Ruby to Track Events & Error Messages

Logging is the process of saving information about what your Ruby application is doing. It's very helpful, both in development ...
Read More

How to Use The Ruby Uniq Method To Remove Duplicates

With the uniq method you can remove ALL the duplicate elements from an array. Let's see how it works! If ...
Read More

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 ...
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 ...
Read More

String Concatenation & Interpolation in Ruby (With Examples)

Combining multiple strings together is something that you have to do often in Ruby. But how can you do that? ...
Read More

3 Awesome Ways To Use Ruby’s Gsub Method

Let's talk about Ruby's gsub method. First, you'll need a string to play with this method. Why? Because you use ...
Read More

Read This If You Want to Understand Instance Variables in Ruby

If you want to learn about Ruby instance variables, how they work & why they're useful. You're in the right ...
Read More

How to Use The Ruby Begin & Rescue Keywords (With Examples)

Let's talk about the begin keyword in Ruby. What is it? First, you need to understand something. Your Ruby programs ...
Read More

How to Use The Ruby Sequel Gem (With Examples)

What is Sequel? Sequel is a gem that allows you to access your database, no Rails required. You can connect ...
Read More

How to Write Your Own Ruby Methods (Complete Guide)

What is a Ruby method? A method is one, or multiple, lines of Ruby code grouped together with a specific ...
Read More

What Are Rails Parameters & How to Use Them Correctly

Let's talk about Rails parameters! Why are they useful? Users can send data to your web application in three different ...
Read More

Understanding Ruby: String Encoding, ASCII & Unicode

How can strings of characters exist in a world where computers only understand ones & zeros? Well... Just like we ...
Read More

How to Use Ruby’s FFI Module to Play MP3 Files

I want to answer one simple question... What is FFI in Ruby? FFI stands for "Foreign Function Interface". It's a ...
Read More

How to Use Rails link_to Method (With Examples)

Ah, yes. The link_to method. One of the most common helper methods you'll use in your Rails applications. But how ...
Read More

How to Create Temporary Files in Ruby

Creating a temporary file gives you an empty file with a random name inside your O.S. (Operating System) temporary folder ...
Read More

How to Schedule Cron Jobs in Ruby With the Whenever Gem

What is Cron? Cron is a job scheduling system available in Linux & MacOS operating systems. It can be used ...
Read More

How to Use The Redis Database in Ruby

What is Redis? Redis is a kind of in-memory database that has different kinds of data structures you can use ...
Read More

An Overview of Data Structures For Ruby Developers

What is a data structure? A data structure is a specific way to organize & access data. Examples include: Arrays ...
Read More

How to Use The Ruby Select Method (With Examples)

You can use the select method in Ruby to filter an array of objects. For example, you can find all ...
Read More

The Ultimate Guide to Rails Rendering

The ultimate goal of your Ruby on Rails application is to render a view. A view is what the user ...
Read More

Understanding Ruby: Variable Scope & Binding Objects

Scope is an important concept to understand for all Ruby developers. It's the source of many error messages & confusion ...
Read More

How to Use AJAX With Ruby on Rails

The normal flow of visiting a website is that you load a page & if you want to see new ...
Read More

Ruby Interpreter Options & How to Use Them Correctly

A Ruby interpreter is a program that reads & runs Ruby code. But... Did you know that the default Ruby ...
Read More

How to Tell Your Ruby Program to Stop Running Early

How do you stop a Ruby program early? Normally a program will run until it's done processing all the instructions ...
Read More

7 Interesting Ruby Code Examples

One way to learn new Ruby tricks, patterns & methods is to read code others have written. But where do ...
Read More

How to Write Your Own Classes in Ruby (Tutorial + Examples)

What is a class? A class in Ruby is the basic building block for Object-Oriented Programming & it helps you ...
Read More

What is Rake in Ruby & How to Use it

Rake is a popular task runner in Ruby. What is a task? Making a backup of your database Running your ...
Read More

Understanding Boolean Values in Ruby

What is a boolean? A boolean is a value used in a logic statement to say if something is considered ...
Read More

Input & Output (IO) In Ruby: The Definitive Guide

I/O stands for Input/Output. By input we mean all the data & information that comes into something (computer, Ruby method, ...
Read More

Which Ruby IDE Should You Use?

You're going to spend a lot of your time as a developer inside the editor, so it important to use ...
Read More

5 Types Of Ruby Comments & How to Use Them Correctly

What are comments in Ruby? A Ruby comment adds information to your code that may be helpful for you or ...
Read More

What is Dry-rb?

Looking for some new & interesting gems to try? Then have a look at dry-rb, a set of gems that ...
Read More

How to Use The Initialize Method in Ruby

The initialize method is part of the object-creation process in Ruby & it allows you to set the initial values ...
Read More

Helpful Math Concepts For Ruby Developers (Modulo, Binary, Methods)

Let's talk about Math in Ruby. Do you need to know math to become a good programmer? It depends! If ...
Read More

How to Control a Web Browser From Ruby With Watir

Did you know that you can control your web browser with Ruby? The Watir gem allows you to do this ...
Read More

What is Inheritance in Ruby?

Inheritance is a fundamental OOP feature that allows you to create a more specific & specialized version of a class ...
Read More

How Do You Use Environment Variables in Ruby?

An environment variable is a key/value pair, it looks like this: KEY=VALUE We use these variables to share configuration between ...
Read More

What is A Matrix & How to Use It in Ruby?

A matrix is a 2D (2-dimensional) array that can be used to store & work with spreadsheet-like data. They can ...
Read More

How to Create Ruby Objects That Describe Themselves

In this article you'll learn how the Ruby inspect method works & why do we use it. When you print ...
Read More

How to Build Command-Line Applications (CLI) with Ruby

Many people forget that Ruby can do things that aren't web applications. In this article, I want to show you ...
Read More

MiniMagick Gem: How to Transform Images Using Ruby

If you work with any kind of images in your Ruby application there is a good chance that you'll want ...
Read More

How to Use The VCR Gem to Improve Your Testing Suite

If your Ruby application uses any kind of external API then you probably have faced the problem of slow tests ...
Read More

What is A REPL in Ruby? (IRB, Pry & More)

REPL stands for Read-Eval-Print-Loop. It's a program that allows you to type Ruby code & see the result directly. One ...
Read More

How to Use State Machines in Ruby

Imagine a traffic light... It can be red, green or yellow. When it changes colors, the next color is based ...
Read More

How to Run System Commands From Ruby

If you want to run an external command from Ruby... ...like wkhtmltopdf to convert an HTML file into a PDF ...
Read More

How To Use Heredoc in Ruby

What is a heredoc? A heredoc is a way to define a multiline string, while maintaining the original indentation & ...
Read More

Dup vs Clone in Ruby: Understanding The Differences

Did you know that you can copy an object in Ruby? Not only that, but there are two different methods ...
Read More

What Is MJIT in Ruby 2.6 & How Does It Work?

Ruby's performance has been improving a lot, version after version... and the Ruby development team is making every effort to ...
Read More

How to Use The Ruby Alias Keyword

You can give an alternative name to a Ruby method in two ways: alias (keyword) alias_method Because they do the ...
Read More

9 New Features in Ruby 2.6

A new version of Ruby is coming with new features & performance improvements. Would you like to keep up with ...
Read More

Ruby Templating Engines: ERB, HAML & Slim

ERB is a templating engine. A templating engine allows you to mix HTML & Ruby. This helps you generate your ...
Read More

How to Use attr_accessor, attr_writer & attr_reader

This article is about attribute accessors (attr_accessor) in Ruby. If you're in a hurry, scroll down. Because I would like ...
Read More

Ruby Coding Challenges & How to Solve Them

Doing coding challenges is an excellent way to improve your Ruby & problem-solving skills. Why? Because you put all your ...
Read More

How to Check If a Variable is Defined in Ruby

Ruby has this defined? keyword that helps you check if a variable is defined or not. If the variable exists ...
Read More

Understanding The Differences Between Puts, Print & P

There are many ways to print something in Ruby. Here are the most useful: puts print p But how are ...
Read More

How to Use RSpec Mocks (Step-By-Step Tutorial)

What is a mock in RSpec? (Or a mock in general, because this isn't a concept unique to RSpec.) A ...
Read More

How to Read & Parse CSV Files With Ruby

CSV stands for "Comma-Separated Values". It's a common format for exporting & importing data. For example: You can export your ...
Read More

How to Use Ruby Any, All, None & One

Today you'll learn about 4 Enumerable methods that will help you check a conditional statement against an array of elements, ...
Read More

How to Use the Ruby Grep Method (With Examples)

Let's talk about the grep method. What can this method do for you? You can use Grep to filter enumerable ...
Read More

What is Ruby on Rails & Why Is It Useful?

Ruby on Rails is the most popular open-source web application framework. It's built with the Ruby programming language. You can ...
Read More

How to Use The Ruby Map Method (With Examples)

Map is a Ruby method that you can use with Arrays, Hashes & Ranges. The main use for map is ...
Read More

Ruby Private & Protected Methods: Understanding Method Visibility

What is a private method in Ruby? It's a type of method that you can ONLY call from inside the ...
Read More

How To Delegate Methods in Ruby

This article is about method delegation in Ruby. You're going to learn how to use the delegate method, the Forwardable ...
Read More

Ruby Gems, Gemfile & Bundler (The Ultimate Guide)

A Ruby gem packages together Ruby code in a way that is easy to share with others. Gems solve mostly ...
Read More

How to Use Ruby Conversion Methods (to_s, to_a, to_str)

You're working with an integer but you would like to use string methods (like gsub) instead. What can you do? ...
Read More

How to Use The Ruby Super Keyword

What does the super keyword do in Ruby? It calls a method on the parent class with the same name ...
Read More

Rack Explained For Ruby Developers

Would you like to know what goes on behind the scenes of Rails, Sinatra, and other Ruby web frameworks? Then ...
Read More

Solving the N-Queens Problem With Ruby

N-Queens is an interesting coding challenge where you have to place N queens on a N * N board. It ...
Read More

How to Use The Ruby Set Class

What is a Ruby set? A set is a class that stores items like an array... But with some special ...
Read More

The Ultimate Guide to HTTP Requests in Ruby

If you'd like to get information from a website, or if you'd like to submit forms, upload files... ...you'll need ...
Read More

The Definitive RSpec Tutorial With Examples

Would you like to learn how to write tests for your Ruby applications using RSpec? Then you're in the right ...
Read More

Everything You Need to Know About Ruby Operators

Ruby has a lot of interesting operators, like the spaceship operator (<=>), the modulo assignment operator (%=), and of course ...
Read More

Ruby’s Powerful Method Arguments & How To Use Them Correctly

I got an email asking for my opinion about when to use keyword arguments. I thought I'd expand my answer ...
Read More

Why Do We Create Classes?

Following my last article, why do we use nil, I thought it'd be a good idea to ask this question ...
Read More

Why Do We Use Nil?

I was having a chat with a friend about a piece of Ruby code & the topic of return values ...
Read More

How To Use The Singleton Pattern In Ruby (And Why You Should Avoid It)

Have you ever wanted to create a class that can only have one instance? Yes? No? Maybe? Well... That's exactly ...
Read More

How To Dramatically Improve Your Ruby Code With Fundamental OOP Principles

Two of the most important object-oriented principles are cohesion & coupling. Cohesion is about the relationship between all the methods ...
Read More

How to Use The Strategy Design Pattern in Ruby

Let's talk about the strategy design pattern! This design pattern helps you change the main algorithm inside a method. You ...
Read More

How To Use The Decorator Pattern in Ruby

The decorator design pattern... What is it, and how can you use this pattern in your Ruby projects? The decorator ...
Read More

How To Create A Memory Leak in Ruby

There are a few articles out there about how to find memory leaks. But how about creating one? I think ...
Read More

Profiling Ruby’s Memory Allocation with TCmalloc

Everytime Ruby needs to request memory from the operating system it has to call the malloc function. This function is ...
Read More

The Definitive Guide To Time Complexity For Ruby Developers

Time complexity is one of the most interesting concepts you can learn from computer science, and you don't need a ...
Read More

How to Write a Ruby C Extension (Step-by-Step)

Writing a C extension allows you to interact with Ruby from C. You may want to this if there is ...
Read More

What Are Ruby Symbols & How Do They Work?

A symbol looks like this: :testing Some people confuse symbols with variables, but they have nothing to do with variables ...
Read More

Functional Programming In Ruby (Complete Guide)

Maybe you just heard about functional programming & have some questions. Like... What is functional programming exactly? How does it ...
Read More

Ruby String Methods (Ultimate Guide)

A string is a sequence of characters. Strings are objects so they have a lot of methods you can use ...
Read More

Everything You Need to Know About Nil

Nil... What is it, really? Well, nil is just a Ruby object. As you can see here: nil.class # NilClass ...
Read More

Ruby Is Hiding Errors From You!

Ruby will intentionally hide some errors & exceptions from you. Sometimes this can be useful. Like when using the Kernel#loop ...
Read More

Learn to Implement & Use Prefix Trees in Ruby

A prefix tree (also known as a trie) is a data structure that helps you organize a word list & ...
Read More

Atom Tricks, Plugins & Shortcuts for Ruby Developers

If you are using Atom for Ruby development then you probably know that there are plugins (packages in Atom) that ...
Read More

Build Your Own Link Shortener App with Ruby & Sinatra

If you are looking for a little project to work on & practice your Ruby skills then you are in ...
Read More

Performance Improvements in Ruby 2.5

New Ruby versions keep improving & Ruby 2.5 is no different. Ruby 2.5 is introducing some optimizations: String interpolation will ...
Read More

Turn Rows Into Columns With The Ruby Transpose Method

Today you are going to learn how to deal with grids in Ruby using the Ruby transpose method. Imagine that ...
Read More

Array#zip Method

Let's say that you want to compare two arrays, element by element so you can find the differences. Or maybe ...
Read More

7 Little-Known Ruby Methods To Help You Write Better Code

Did you know that using the right Ruby method can save you a lot of work? The more methods you ...
Read More

Build an Image Downloader in Ruby

Build an Image Downloader in Ruby Watch this video to learn how to build an image dowloader program step-by-step using ...
Read More

Code Reading Adventures: Awesome Print Gem

Awesome print is a nice gem that formats your output in irb & pry to make it more readable. For ...
Read More

A Quick Analysis of How Sinatra Works

Sinatra is a Ruby web framework. It's like Rails little brother... Let's explore how Sinatra works: What happens when you ...
Read More

Practical Linked List in Ruby

This is the 3rd entry in the "Practical Computer Science in Ruby" series! Today we are going to talk about ...
Read More

How to Sort Arrays & Hashes in Ruby (Examples Included)

How many ways are there to sort an array in Ruby? More than you think... Even though Array has only ...
Read More

Everything You Need to Know About Ruby Constants

What is a Ruby constant? A constant is a type of variable which always starts with a capital letter. It ...
Read More

The Hidden Costs of Metaprogramming

Metaprogramming sounds like a very fancy word, but is it any good? It can be useful, but many people don't ...
Read More

There Is No Magic in Ruby

You may have heard (or even said yourself) that Rails / Ruby has too much magic... But where does that ...
Read More

Practical Graph Theory in Ruby

This is the next installment in the "Practical Computer Science" series, where you will learn how to apply classic computer ...
Read More

StringIO – An Object That Behaves Like a File?

Are you looking for an object that behaves like an IO object (files, sockets, etc), but that you can control ...
Read More

Stop Using Case Statements in Ruby

Are you using the full power of OOP (Object-Oriented Programming) or are you missing out? If you are taking decisions ...
Read More

Ruby Internals: Exploring the Memory Layout of Ruby Objects

Would you like a quick tour of Ruby internals? Then you're in for a treat. Because... We're going to explore ...
Read More

Practical Computer Science in Ruby: Using Stacks to Solve Problems

If you don't have a CS (Computer Science) degree you might feel like you are missing out on something... Or ...
Read More

How to Make Your Classes More Powerful by Implementing Equality

How do you compare two things in Ruby? Using == as you already know... but did you know that == ...
Read More

15 Weird Things About Ruby That You Should Know

15 Weird Things About Ruby That You Should Know By Jesus Castello Ruby is an amazing language with a lot ...
Read More

Hash Tables Explained

One of my favorite data structures is the hash table because it's simple & powerful. You probably have used it ...
Read More

Packing & Unpacking: A Guide to Reading Binary Data in Ruby

In this article you'll learn about the Ruby pack & unpack methods! But why do we need these methods? Working ...
Read More

How To Spy on Your Ruby Methods

Ruby has a built-in tracing system which you can access using the TracePoint class. Some of the things you can ...
Read More

9 New Features in Ruby 2.4

It has become a tradition to release new Ruby versions on Christmas. And in this post I want to cover ...
Read More

How to Write a Port Scanner in Ruby

Why would you want to write a port scanner? Writing a port scanner is a great way to learn the ...
Read More

A Quick Analysis of How Minitest Works

What is Minitest? Minitest is a Ruby testing library, it allows you to write tests for your code TDD style ...
Read More

What’s Happening in Your Ruby Application?

If you're wondering what's going on with your Ruby application... There are no fancy GUI tools... But we have the ...
Read More

Build Your Own Web Server With Ruby

Have you ever built your own web server with Ruby? We already have many servers, like: Puma Thin Unicorn But ...
Read More

How Numbers Work in Ruby: Understanding Integers, Floats & Bigdecimal

Ruby 2.4 merged Fixnum & Bignum into the same class (Integer) so I think this is a good time to ...
Read More

Writing a Shell in 25 Lines of Ruby Code

If you use Linux or Mac, every time you open a terminal you are using a shell application. A shell ...
Read More

Ruby Project: Build Your Own Linux Tools (A Practical Guide)

Let's do a project together! Tools like ps, top & netstat are great. They give you a lot of information ...
Read More

Ruby Ranges: How Do They Work?

What is a Range in Ruby & how does it work? A range is an object which has a starting ...
Read More

5 Useful Examples From The Ruby Standard Library

The Ruby Standard Library is a series of modules & classes that come with Ruby but are not part of ...
Read More

How to Generate Weighted Random Numbers

Random numbers usually follow what we call a 'uniform distribution', meaning that there is the same chance that any of ...
Read More

Ruby Metaprogramming: Real-World Examples

You may have read about Ruby metaprogramming before. But... It can be a bit confusing if you don't have a ...
Read More

Learn to Use the Twitter API with Ruby

Do you want to learn how to write a Twitter application using Ruby? Then you are in the right place! ...
Read More

A Basic Guide to The Ruby Enumerable Module (+ my favorite method)

What is Enumerable? Enumerable is a collection of iteration methods, a Ruby module, and a big part of what makes ...
Read More

Exploring MRI Source Code

If you have been using Ruby for a while you are probably curious about how some things work under the ...
Read More

The Ultimate Guide to Blocks, Procs & Lambdas

Ruby blocks, procs & lambdas. What are they? How do they work? How are they different from each other? You ...
Read More

11 Ruby Tricks You Haven’t Seen Before

Looking for some cool Ruby tricks? You found them! In this article I want to share with you some of ...
Read More

Understanding Mutable Objects & Frozen Strings

Let's talk about mutability. What does it mean for an object to be mutable? Don't let the fancy word confuse ...
Read More

How to Use Ruby Time & Date Classes

Time is a class in Ruby that helps you represent a specific point in time. After reading this article you'll ...
Read More

Ruby Refactoring Techniques: An Introduction

If you aren't familiar with the term, refactoring is the act of improving the quality of code without changing what ...
Read More

The Many Uses Of Ruby Case Statements

Whenever you need to use some if / elsif statements you could consider using a Ruby case statement instead. In ...
Read More

Ruby NLP: N-gram Analysis For Fun & Profit

What would you do if you are given a big collection of text & you want to extract some meaning ...
Read More

How to Use Recursion & Memoization in Ruby

What is recursion in Ruby? Recursive functions are those that keep calling themselves until they hit an end goal (also ...
Read More

Static Analysis in Ruby

Let's say that you want to parse your source code to find all your methods, where they are defined & ...
Read More

How to Debug & Fix Your Ruby Programs

How often does your program do exactly what you want the first time around? Many times our programs dont't work ...
Read More

How to Use Ruby Threads: An Easy To Understand Tutorial

What is a thread in Ruby? Threads make your Ruby programs do multiple things at the same time. Things like: ...
Read More

Mastering Ruby Regular Expressions

Ruby regular expressions (ruby regex for short) help you find specific patterns inside strings, with the intent of extracting data ...
Read More

How to Use Struct & OpenStruct in Ruby

What is a Struct in Ruby? Let's say that you need to store related data together but you don't need ...
Read More

How To Read & Write Files in Ruby (With Examples)

Today you'll learn how to read & write files in Ruby so you can extract the contents, create new files, ...
Read More

How to Use Ruby’s Array Class (With Examples + Useful Method List)

What's an array? An array is a built-in Ruby class, which holds a list of zero or more items, and ...
Read More

Ruby Network Programming

Do you want to create custom network clients & servers in Ruby? Or just understand how that works? Then you ...
Read More

How to Build a Parser With Ruby

Parsing is the art of making sense of a bunch of strings and converting them into something we can understand ...
Read More

How to Write Your Own Caesar Cipher Encoder

Have you ever heard of the Caesar cipher? Julius Caesar used this technique to conceal secret messages from his enemies! ...
Read More

How to Generate Random Numbers & Strings in Ruby

You can generate Ruby random numbers & strings using what you'll learn in this post! With a random number you ...
Read More

Alphanumeric sorting

Time for a bit more sorting. Today our task is to sort an array of file names based on the ...
Read More

How to Parse HTML in Ruby

Are you trying to parse HTML with Ruby? This task can be a bit difficult if you don't have the ...
Read More

Ruby String Formatting

Let's talk about how you can format strings in ruby. Why would you want to format a string? Well, you ...
Read More