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
110: Bundler Groups and Platforms
A few years ago, I was helping a junior dev deploy a Ruby app to a Linux VPS. On his MacBook, everything was humming along perfectly. But the moment he ran bundle install on the server, the whole process crashed with a cryptic error about native extensions. To make matters worse, the server was spending five minutes trying to compile pry-byebug and rspec—gems that have absolutely no business being on a production server. He was frustrated, and I had to explain that his Gemfile was treating the production server exactly like his local development environment.
Slicing Your Gems into Environment Groups
You don't want every gem you use to be loaded in every environment. If you're using rspec for testing or better_errors for debugging, loading those into production is a waste of memory and, in some cases, a legitimate security risk. Bundler lets you categorize these using groups.
Instead of just listing gems at the top level of your Gemfile, you can wrap them in a block. Here is how I usually structure a professional Gemfile:
gem 'pg' # Needed everywhere
group :development, :test do
gem 'rspec'
gem 'pry-byebug'
end
group :development do
gem 'better_errors'
end
group :production do
gem 'rack-timeout'
end
When you run bundle install, Bundler still installs everything by default. However, when you're actually deploying to a server, you can tell Bundler to ignore specific groups. I always use the --without flag in my deployment scripts: bundle config set --local without 'development test'. This ensures the production server stays lean and doesn't waste time installing tools you'll never use in a live environment.
Solving the "Works on My Machine" Platform Clash
Now, let's talk about platforms. This is where things get gritty. Some gems are "pure Ruby," but others are "native extensions"—they actually compile C code during installation. Because a MacBook (especially the M1/M2 ARM chips) is fundamentally different from a Linux server (x86_64), the Gemfile.lock needs to know about both environments.
If you generate your lockfile on macOS and then push it to a Linux server, you might see an error saying the lockfile was created for a different platform. I used to just delete the lockfile and run bundle install on the server to fix this, but that's a terrible habit because it risks upgrading other gems unexpectedly.
The right way to handle this is to explicitly add the target platforms to your lockfile from your local machine. If you know your app will run on a standard Linux server, run this command:
bundle lock --add-platform x86_64-linux
If you're deploying to a Docker container or a specific cloud provider, you might also see ruby (the generic platform) or arm64-linux. By adding these platforms, Bundler resolves the dependencies for all of them and stores the correct versions in the lockfile. When the server sees the lockfile already has the x86_64-linux resolution, it just works without complaining.
📋 Practical Task
Exercise: Pruning the Production Environment and Syncing Platforms
You have been handed a Gemfile for a project that is currently "bloated." The developer previously put everything in the global scope, and the production deployment is failing because of a platform mismatch between the developer's Mac and the Ubuntu server.
Your Goal: Modify the provided Gemfile and use the terminal to prepare the lockfile for a Linux environment.
# Current Gemfile
source 'https://rubygems.org'
gem 'rails'
gem 'sqlite3'
gem 'rspec'
gem 'factory_bot_rails'
gem 'pry-byebug'
gem 'aws-sdk-s3'
- Rewrite the Gemfile so that
rspecandfactory_bot_railsare in a group for bothdevelopmentandtest. - Move
pry-byebuginto adevelopment-only group. - Assuming you are on a non-Linux machine, write the exact command you would run in the terminal to ensure the
Gemfile.locksupports thex86_64-linuxplatform without deleting the lockfile. - Write the command you would run on the production server to install the gems while skipping the development and test groups.
There are no comments for now.