All 150+ RubyGuides Articles

Ruby Tutorial For Beginners

Exploring Ruby Hashes: A Deep Dive into Data Manipulation

What is a Ruby hash? A hash is an efficient data structure that lets you store data in UNIQUE key-value ...

What Is Self in Ruby & How to Use It (Explained Clearly)

If you're learning Ruby you may find the use of the "self" keyword very confusing. How does it work? What ...

What is Scaffolding in Ruby on Rails?

You may be learning Rails & you read that you have to create a "scaffold" to get your Rails application ...

How to Work With Directories in Ruby

Did you know that you can navigate your file system with Ruby? With the Ruby "Dir" class. You can list ...

7 Major Differences Between Java & Ruby

How do you move from Java to Ruby? In this guide, you'll learn what are the major differences between the ...

How to Use Rails Helpers (Complete Guide)

What are helpers in Rails? A helper is a method that is (mostly) used in your Rails views to share ...

Understanding Yield & Yield_Self in Ruby (Complete Guide)

What does the word "yield" mean in Ruby? And what does it do exactly? Well... Yield is a keyword (meaning ...

New Features, Methods & Improvements in Ruby 2.7

Ruby never stops improving! Version 2.7 is here with new features, methods & performance improvements. It's was released on December ...

Ruby Programming Uses: What Can You Create?

The Ruby programming language has many practical uses. But here's the thing... Many people are attracted to Ruby because of ...

How to Use Flash Messages in Rails

What are flash messages? A flash message is a way to communicate information with the users of your Rails application ...

What Everyone Should Know About Fibers in Ruby

If you want to get the most performance out of your Ruby projects we have to explore fibers & how ...

How to Use Queues in Ruby

A queue is like a waiting list. Imagine you're waiting in line to buy the latest Apple product, getting a ...

How to Use The Ruby Gets & Chomp Methods

You're writing a Ruby program & you want to ask the user a question... How can you do that? Well, ...

How to Use Scopes in Ruby on Rails

What is a scope in Rails & why is it useful? Well... Scopes are custom queries that you define inside ...

Ruby Syntax Reference For Beginners

This is a Ruby syntax reference. Learning Ruby can be overwhelming with everything you have to remember. That's why I ...

How to Use The Ruby Ternary Operator (?:)

What is a ternary operator in Ruby? A ternary operator is made of three parts, that's where the word "ternary" ...

Rails Design Patterns: Presenter & Service Objects

Why do we need design patterns? The problem is that Rails architecture, Model-View-Controller, gives you a basic structure to put ...

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

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

Zeitwerk & Module Autoloading in Ruby (Explained Clearly)

This article explains class & module autoloading in Ruby. Including the new "Zeitwerk" gem which is part of Rails 6 ...

Why Do We Need Application Servers in Ruby? (Like Puma)

What's this "Puma" thing that starts running when you do rails server? It's an app server! Let me explain what ...

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

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

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

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

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? ...

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

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

How to Use The “Begin” & “Rescue” Keywords in Ruby

A common problem in Ruby is that you get error messages, which in technical terms we call "exceptions". These exceptions ...

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

Ruby Functions & Methods: How to Define Your Own

What is a Ruby method? A method is a set of one or more lines of Ruby code that are ...

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

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

Ruby FFI Module Tutorial (Example: Play MP3 with VLC)

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

How to Use Rails link_to Method (With Examples)

Rails link_to method! One of the most common helper methods you'll use in all your Rails applications. But how does ...

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

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

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

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

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

The Ultimate Guide to Rails Rendering

What's rendering in Rails? Rendering is the ultimate goal of your Ruby on Rails application. You render a view, usually ...

Understanding Variable Scope & Binding Objects in Ruby

Scope is an important concept to understand for all Ruby developers. Why? Because it's the source of many error messages ...

How to Use AJAX With Ruby on Rails

Let's understand why AJAX exists, so you can get a better idea of how to use it in your Rails ...

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

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

7 Interesting Ruby Code Examples

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

How to Write Your Own Classes in Ruby (Explained Clearly)

What is a class in Ruby? Classes are the basic building blocks in Object-Oriented Programming (OOP) & they help you ...

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

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

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, ...

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

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

What is Dry-rb?

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

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

Math With Ruby: Modulo Operator, Binary & More

Do you need to know math to become a good programmer? It depends! If you're just going to be writing ...

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

Ruby Inheritance Explained – Learn OOP Today!

Class inheritance is a fundamental OOP (Object-Oriented Programming) feature that helps you create a more specific & specialized version of ...

How To 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 options ...

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

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

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

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

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

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

How to Use The AASM Gem To Create State Machines in Ruby

Today you'll learn about state machines, how they work & how to use them in your Ruby projects with the ...

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

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 & ...

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

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

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

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

Ruby Templating Engines: ERB, HAML & Slim

ERB is a templating engine. A templating engine allows you to mix HTML & Ruby so you can generate web ...

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

Ruby Interview Coding Challenges & How to Solve Them

Doing coding challenges is an excellent way to improve your Ruby & problem-solving skills. And to prepare for coding interviews! ...

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

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

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

How to Read & Parse CSV Files With Ruby

CSV stands for "Comma-Separated Values". It's a common data format which consist of rows with values separated by commas. It's ...

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, ...

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

What is Ruby on Rails & Why Is It Useful?

Ruby on Rails (sometimes RoR) is the most popular open-source web application framework. It's built with the Ruby programming language ...

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

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

How To Delegate Methods in Ruby & Ruby on Rails

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

Ruby Gems, Gemfile & Bundler (The Ultimate Guide)

What is a Ruby gem? A gem is a package that you can download & install. When you require an ...

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? ...

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

Rack Explained For Ruby Developers

What is happening behind the scenes of every Rails, Sinatra, and other Ruby web frameworks? The answer is Rack, the ...

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

Ruby Sets – Examples, Operators & Methods

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

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, etc. You'll ...

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

Everything You Need to Know About Ruby Operators

Ruby has a lot of interesting operators. Like: The spaceship operator (<=>) The modulo assignment operator (%=) The triple equals ...

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

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

Why Do We Use Nil?

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

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

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

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

The Decorator Design Pattern in Ruby

What is the decorator design pattern? And how can you use this pattern in your Ruby projects? The decorator design ...

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

Profiling Ruby’s Memory Allocation with TCmalloc

How does memory allocation work in Ruby? Ruby gets memory in chunks, called pages, new objects are saved here. Then ...

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

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

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

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

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

Everything You Need to Know About Nil

Nil... What is it, really? Well, nil is a special Ruby object used to represent an "empty" or "default" value ...

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

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 & ...

Atom Editor: 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 ...

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

Performance Improvements in Ruby 2.5

New Ruby versions keep improving & Ruby 2.5 is no different. Ruby 2.5 introduces these optimizations: String interpolation will be ...

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

Array#zip Method

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

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

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

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

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

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

Sorting an array in Ruby is easy! You don't need to write any fancy algorithms to get the result you ...

Everything You Need to Know About Ruby Constants

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

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

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

How to Use Struct & OpenStruct in Ruby

What is a Struct in Ruby? A struct is a built-in Ruby class, it's used to create new classes which ...

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

StringIO in Ruby: How it Works & How to Use it

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

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

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

How to Use Stacks in Ruby to Solve Problems

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

How to Compare Two Objects in Ruby By Implementing Equality

Equality means that two things are the same. In Ruby, we compare objects & their values to find out if ...

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

Hash Tables Explained

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

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

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

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

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

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

What’s Happening in My Ruby Application?

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

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

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

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

Ruby Project Idea: Build Your Own Linux Tools

Let's make a project together! Linux tools like ps, top & netstat are great. They give you a lot of ...

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

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

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

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

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! ...

Complete Guide to The Ruby Enumerable Module

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

Exploring MRI Source Code

If you have been using Ruby for a while you may be curious about how some things work under the ...

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

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

Ruby Freeze Method – Understanding Object Mutability

What does it mean for an object to be mutable? Don't let fancy words confuse you, "mutability" just means that ...

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

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

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

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

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

Static Analysis in Ruby

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

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

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: ...

Mastering Ruby Regular Expressions

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

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, ...

How to Use Ruby’s Array Class (Examples + Useful Methods)

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

Ruby Network Programming

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

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

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! ...

How to Generate Random Numbers & Strings in Ruby

If you want to learn how to generate random numbers & strings in Ruby, then you're in the right place ...

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

Ruby String Formatting

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