Questions

Ruby questions

Choose a question page, learn the concept, then test your understanding with a quiz.

How to Call Shell Commands from Ruby and Capture Output

Learn how to run shell commands in Ruby, capture output, check exit status, and choose the right method for scripts and apps.

rubyshellinterop

How to Check Whether a String Contains a Substring in Ruby

Learn how to check if a string contains a substring in Ruby using include?, match, and multiline string examples.

rubystring

How to Check if a Hash Key Exists in Ruby

Learn how to check whether a specific key exists in a Ruby hash using key?, has_key?, and include? with clear examples.

rubydata-structuresassociative-array

How to Check if a Value Exists in an Array in Ruby

Learn how to check whether a value exists in a Ruby array using include?, with examples, common mistakes, and practical use cases.

rubyarrays

How to Convert a String to Lowercase or Uppercase in Ruby

Learn how to convert strings to lowercase or uppercase in Ruby using upcase, downcase, and related methods with simple examples.

rubystringuppercaselowercase

How to Disable RI and RDoc by Default for gem install in Ruby

Learn how to make gem install skip RI and RDoc by default using RubyGems configuration, with examples and common mistakes.

rubyrubygems

How to Drop Columns in a Rails Migration

Learn the Rails migration syntax for dropping database columns safely, with examples, reversibility, and common mistakes.

rubyruby-on-railsdatabaseactiverecord

How to Execute a Command Line Binary in Node.js

Learn how to run command line binaries in Node.js using child_process, with examples, safety tips, and real CLI use cases.

rubyjavascriptnode.jscommand-line-interface

How to Fix RubyGems Permission Errors When Installing Gems in Ruby

Learn why RubyGems permission errors happen and how to safely install gems or update RubyGems without write access issues.

rubymacosrubygems

How to Generate a Random Number in Ruby

Learn how to generate random numbers in Ruby, including ranges, inclusive and exclusive bounds, and beginner-friendly examples.

rubyruby-on-railsruby-on-rails-3ruby-on-rails-4

How to Generate a Random String in Ruby

Learn how to generate random strings in Ruby using arrays, ranges, and SecureRandom with clear examples and common pitfalls.

rubyrandompasswords

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.

rubyruby-on-railsurl

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.

rubyrubygems

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.

rubyregex

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.

rubycommand-linerakecommand-line-arguments

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.

rubyarraysrandom

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.

rubyrubygemsrvm

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

rubystring

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.

rubycommentsmultilineblock-comments

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.

rubyswitch-statementconditional-statements

Page 1 of 2 - 32 questions

PreviousNext