Questions
Ruby questions
Choose a question page, learn the concept, then test your understanding with a quiz.
How to Get the Current Absolute URL in Ruby on Rails
Learn how to get the full current URL in a Ruby on Rails view, including protocol, host, path, and query string.
How to Install a Specific Version of a Ruby Gem
Learn how to install a specific gem version in Ruby using the gem command, with syntax, examples, common mistakes, and real-world usage.
How to Map with Index in Ruby
Learn how to transform arrays with both value and index in Ruby using map.with_index, each_with_index, and practical examples.
How to Match All Regular Expression Occurrences in Ruby
Learn how to find every regex match in Ruby using scan, to_enum, and MatchData with clear examples and common pitfalls.
How to Pass Command Line Arguments to a Rake Task in Ruby
Learn how to pass command line arguments to Rake tasks in Ruby, including task parameters, environment variables, and calling tasks from other tasks.
How to Pause Execution in Ruby with sleep
Learn how to make a Ruby program wait using sleep, including syntax, examples, timing behavior, and common mistakes.
How to Pick a Random Element from an Array in Ruby
Learn how to choose a random item from an array in Ruby using Array#sample, with examples, mistakes to avoid, and practical use cases.
How to Remove RVM (Ruby Version Manager) from Your System
Learn how to remove RVM from your system safely, including shell cleanup, PATH changes, and verifying Ruby environment settings.
How to Remove Whitespace in Ruby: strip, lstrip, rstrip, and gsub
Learn how to remove whitespace in Ruby using strip, lstrip, rstrip, and gsub, and how they compare to PHP trim().
How to Return a 404 Response in Ruby on Rails
Learn how to return or render a 404 response in Rails, when to use it, and common patterns for missing records and custom not found pages.
How to Sum an Array of Numbers in Ruby
Learn how to sum numbers in a Ruby array using sum, inject, and each, with examples, common mistakes, and a practical mini project.
How to Undo a Rails Generator: Reversing `rails generate` in Ruby on Rails
Learn how to reverse `rails generate` in Rails, remove created files, and roll back route and config changes safely.
How to Undo a Scaffold in Rails
Learn how to undo a scaffold in Rails using generators, migrations, and cleanup steps with practical examples for beginners.
How to Uninstall RVM on Ubuntu: Understanding Safe Tool Removal
Learn how to uninstall RVM on Ubuntu safely, remove shell changes, and understand what a version manager modifies on your system.
How to Update Ruby on macOS Yosemite with Homebrew
Learn how to update Ruby on macOS Yosemite using Homebrew, set the correct PATH, and verify the newer Ruby version works.
How to Write Multi-Line Comments in Ruby
Learn how multi-line comments work in Ruby, including =begin/=end, line comments, common mistakes, and practical Ruby examples.
How to Write a Switch Statement in Ruby
Learn how switch-style logic works in Ruby using `case`, `when`, and `else`, with examples, common mistakes, and practical usage tips.
How to Write to a File in Ruby
Learn how to write text files in Ruby, save database results, and use Ruby file handling methods with simple examples.
Pretty Formatting JSON Output in Ruby on Rails
Learn how to pretty format JSON in Ruby on Rails using built-in Ruby tools, with examples, pitfalls, and practical debugging use cases.
Rails Database Tasks Explained: db:migrate vs db:reset vs db:schema:load
Learn the difference between Rails db:migrate, db:reset, and db:schema:load with examples, use cases, mistakes, and a practical mini project.