Questions
Ruby questions
Choose a question page, learn the concept, then test your understanding with a quiz.
Calling a Class Method from an Instance in Ruby
Learn how to call a class method from an instance in Ruby using self.class, with examples, pitfalls, and practical usage patterns.
Calling an Overridden Monkey-Patched Method in Ruby
Learn how to call the original method when monkey patching in Ruby, including alias_method patterns, examples, pitfalls, and practical usage.
Convert a Unix Timestamp to Ruby DateTime
Learn how to convert Unix timestamps to Ruby DateTime and Time objects, with examples, differences, pitfalls, and practical Ruby usage.
Difference Between `and` and `&&` in Ruby
Learn the difference between `and` and `&&` in Ruby, including precedence, assignment behavior, and when to use each safely.
Difference Between require and include in Ruby
Learn the difference between require and include in Ruby, when to load a file, and when to mix module methods into a class.
ERB Tags in Rails: Difference Between <% %>, <%= %>, <%# %>, and -%>
Learn what ERB tags mean in Rails: <% %>, <%= %>, <%# %>, and -%>. See syntax, examples, output behavior, and common mistakes.
Fixing Ruby Gem Native Extension Errors: mkmf.rb Can't Find Header Files for Ruby
Learn why Ruby gem installs fail with missing ruby.h, how native extensions work, and how to fix header file errors on Linux servers.
Fixing S3 Endpoint Errors in Ruby AWS SDK
Learn why the S3 bucket endpoint error happens in Ruby AWS SDK and how to fix bucket region, endpoint, and object key issues correctly.
Get All File Names from a Folder in Ruby
Learn how to list all file names from a folder in Ruby using Dir, glob patterns, and filtering, with examples and common mistakes.
Handling Currency and Money in Ruby on Rails
Learn the safest way to store, format, and display money in Rails, including cents, integers, and view helpers for currency output.
How to Add One Array to Another in Ruby Without Creating a Nested Array
Learn how to combine arrays in Ruby without getting nested arrays or nil values. Understand push, concat, +, and flatten clearly.
How to Break Out of a Ruby Block and Return from a Method
Learn how Ruby blocks handle return, break, and next, and how to stop iteration or exit the outer method safely and clearly.
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.
How to Capture Command Output in Ruby: system vs Backticks and Open3
Learn how to get shell command output in Ruby, when system returns only true/false, and how to capture stdout and stderr safely.
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.
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.
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.
How to Check if a Variable Is Defined in Ruby
Learn how to check whether a variable is defined in Ruby using `defined?`, with examples for local, instance, class, and global variables.
How to Convert a Ruby Hash to JSON
Learn how to convert a Ruby Hash to JSON in Ruby and Rails, including require statements, examples, common errors, and best practices.
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.
Page 1 of 6 - 112 questions