Questions
Ruby questions
Choose a question page, learn the concept, then test your understanding with a quiz.
Add a Default Value to an Existing Column in a Rails Migration
Learn how to add or change a default value on an existing database column using Rails Active Record migrations safely.
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.
Check Whether a Value Is an Array in Ruby and Count Items
Learn how to test whether a value is an Array in Ruby and count its elements with is_a?, length, size, and count.
Check for Non-Nil and Non-Zero Values in Ruby
Learn idiomatic Ruby ways to test numeric values for nil and zero, including truthiness, zero?, nonzero?, and safe navigation.
Common Ways to Read Files in Ruby: Methods, Trade-Offs, and Examples
Learn common Ruby file-reading methods, including File.read, File.foreach, File.open, and readlines, with memory and error-handling trade-offs.
Convert CamelCase to snake_case in Ruby with underscore
Learn how to convert CamelCase strings to snake_case in Ruby using ActiveSupport's underscore method and a plain Ruby alternative.
Convert Ruby Hash String Keys to Symbols
Learn how to convert Ruby hash keys from strings to symbols, including nested YAML data, transform_keys, Rails helpers, and safe parsing.
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.
Does Ruby Have Real Multithreading? MRI Threads, GVL, and CPU Cores
Learn how Ruby threads map to OS threads, why MRI's GVL limits CPU parallelism, and when to use Ractors or processes instead.
ERB Tags in Rails: Difference Between <% %>, <%= %>, <%# %>, and -%>
Learn what ERB tags mean in Rails: <% %>, <%= %>, <%# %>, and -%>. See syntax, examples, output behavior, and common mistakes.
Filter Hash Keys with Regular Expressions in Ruby
Learn how to filter Ruby hash keys using regular expressions, select matching choice keys, and join selected values with tab delimiters.
Fix Compass Native Extension Build Errors on macOS (Ruby)
Learn why Ruby gem native extensions fail on macOS when installing Compass, how to identify an FFI/Clang mismatch, and safe ways to fix it.
Fix OpenSSL Header Errors When Installing Ruby Gems on macOS
Learn why native Ruby gems cannot find openssl/ssl.h on macOS and how to pass correct OpenSSL include and library paths.
Fix Ruby require LoadError in Homebrew on macOS
Learn why Homebrew can raise Ruby’s “cannot load such file -- utils/popen” error and safely diagnose or repair a damaged installation.
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.
Page 1 of 8 - 148 questions