Ruby
Completed
-
Section 1: Getting Started
-
Section 2: Core Syntax
-
Section 3: Methods and Blocks
-
Section 4: Object-Oriented Ruby
-
Section 5: Metaprogramming
-
Section 6: Working with Data and Files
-
Section 7: Ruby Frameworks Overview
-
Section 8: Ecosystem and Testing
-
Section 9: Practical Projects
-
Section 10: Interview Practice
-
Section 11: Data Structures and Algorithms in Ruby
-
Section 12: More Practice Exercises
-
Section 13: Enumerable and Functional Style
-
Section 14: More OOP Practice
-
Section 15: More Testing
-
Section 16: Enumerable and Comparable Modules In Depth
-
Section 17: Ruby Standard Library: Core Utilities
-
Section 18: Ruby Standard Library: Data and Security
-
Section 19: Ruby Standard Library: CLI and Text
-
Section 20: Ruby Networking
-
Section 21: Ruby on Rails Deep Dive
-
Section 22: Ruby Metaprogramming Deep Dive
-
Section 23: Ruby Design Patterns
-
Section 24: Ruby Concurrency
-
Section 25: Ruby Testing Deep Dive
-
Section 26: Ruby Gems and Packaging
-
Section 27: Ruby Performance
-
Section 28: More Practice Exercises
-
Section 29: More Interview Practice
-
Section 30: Rails API Development
-
Section 31: Rails Authentication and Authorization
-
Section 32: Rails Testing Deep Dive
-
Section 33: Rails Performance
-
Section 34: Rails Deployment
-
Section 35: Sinatra and Lightweight Ruby Web Apps
-
Section 36: More Ruby Language Deep Dive
-
Section 37: Ruby 3.x Modern Features
-
Section 38: More Data Structures in Ruby
-
Section 39: More Practical Projects
-
Section 40: Ruby Ecosystem Tools
-
Section 41: More Practice and Review
-
Section 42: Final Practice and Mastery
-
Section 43: Ruby Interview Deep Dive
-
Section 44: Ruby Background Processing Deep Dive
-
Section 45: Ruby GraphQL
-
Section 46: Ruby Object Model Deep Dive
-
Section 47: Ruby Hanami Framework Overview
-
Section 48: Ruby gRPC and Protocol Buffers
-
Section 49: Ruby Data Processing
-
Section 50: Ruby Search Integration
-
Section 51: Ruby File Upload and Media
-
Section 52: Ruby Email and Notifications
-
Section 53: Ruby Admin Panels
-
Section 54: Ruby Feature Flags and Experimentation
-
Section 55: Ruby Monitoring and Observability
-
Section 56: Ruby Docker and Deployment Deep Dive
-
Section 57: Ruby Security Deep Dive
-
Section 58: More Advanced Metaprogramming
-
Section 59: More Final Projects
3: Ruby Version Managers
Why can't I just use the Ruby that came with my computer?
If you're on a Mac or Linux, you've probably noticed you already have Ruby installed. Trust me, leave it alone. That's called the "system Ruby," and it's there because the operating system itself relies on it for internal scripts. If you start installing gems into the system Ruby, you'll quickly run into permission errors, and you'll find yourself typing sudo gem install—which is a cardinal sin in the Ruby world. Using sudo to install gems can mess up your system permissions and create a security headache.
A version manager lets you install Ruby into your own home directory. This means you have full control, you don't need root access to install libraries, and if you accidentally break something, you can just delete that version and start over without worrying about your OS crashing.
Which manager should I actually use: rbenv, asdf, or RVM?
You'll see these three names pop up everywhere. RVM was the original heavyweight, but it's a bit "magic" (it overrides a lot of shell commands), which can lead to confusing bugs. rbenv is a leaner, more surgical tool that does one thing well: it manages Ruby versions. Then there's asdf, which is what I personally use these days. asdf is a "universal" manager—it handles Ruby, Node.js, Python, and about a hundred other languages using a single plugin system.
If you only ever plan to touch Ruby, rbenv is a great, simple choice. But if you're a full-stack dev, asdf is a lifesaver because you don't need five different tools for five different languages. Here is how a typical installation flow looks with rbenv:
# Install a specific version
rbenv install 3.2.2
# Set it as your global default
rbenv global 3.2.2
# Verify it's working
ruby -v
# => ruby 3.2.2 (2023-03-30 revision 510e4a7d4d) [x86_64-darwin22]
How do I make a project automatically switch to the right Ruby version?
Imagine you're maintaining an old legacy app that only runs on Ruby 2.7, but you're building a new project on Ruby 3.2. Switching manually every time you cd into a folder is a recipe for frustration—you'll eventually run a command with the wrong version and spend an hour wondering why your gems aren't loading.
The solution is a .ruby-version file. It's a simple text file placed in the root of your project containing nothing but the version number. When you enter that directory, your version manager sees that file and flips the switch for you automatically.
# In /projects/legacy-app/.ruby-version
2.7.8
# In /projects/modern-api/.ruby-version
3.2.2
Now, when you move between these folders in your terminal, running ruby -v will show the version changing instantly. It feels like magic, but it's just a small hook in your shell configuration.
Do I have to reinstall all my gems when I upgrade Ruby?
Short answer: Yes. This is a common point of confusion for beginners. Gems are installed into a directory specific to the Ruby version they were built for. If you move from Ruby 3.1 to 3.2, your 3.1 gems won't be available in 3.2.
While that sounds annoying, it's actually a feature. Many gems use "native extensions" (C code) that must be compiled against the specific version of Ruby you're using. If you could just share gems across versions, your app would crash with cryptic segmentation faults. The workflow is always: install the new Ruby version, then run bundle install to fetch the gems for that specific environment.
📋 Practical Task
Exercise: Establishing a Version-Locked Environment
In this exercise, you will simulate a real-world scenario where you must manage two different project environments on the same machine. Follow these steps using your chosen version manager (rbenv or asdf):
- Create two directories:
~/ruby_legacyand~/ruby_modern. - Install Ruby version
3.0.0and Ruby version3.2.2(or the latest stable version available). - Inside
~/ruby_legacy, create a.ruby-versionfile and set it to3.0.0. - Inside
~/ruby_modern, create a.ruby-versionfile and set it to3.2.2. - Open your terminal and
cdinto the legacy folder. Runruby -vand verify it reports3.0.0. cdinto the modern folder. Runruby -vand verify it reports3.2.2.- Finally, install the
colorizegem while inside theruby_modernfolder, thencdintoruby_legacyand try to runrequire 'colorize'in anirbsession to prove that gems are isolated between versions.
There are no comments for now.