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.

rubyruby-on-railsmigration

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.

rubyclass-method

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.

rubymonkeypatching

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.

rubysyntax

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.

ruby

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.

rubyfile-io

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.

rubyruby-on-railsstringformatting

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.

rubyhashmap

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.

rubydatetimetimestamp

Difference Between `and` and `&&` in Ruby

Learn the difference between `and` and `&&` in Ruby, including precedence, assignment behavior, and when to use each safely.

rubyoperators

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.

rubyclassmoduleinclude

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.

rubymultithreadingconcurrency

ERB Tags in Rails: Difference Between <% %>, <%= %>, <%# %>, and -%>

Learn what ERB tags mean in Rails: <% %>, <%= %>, <%# %>, and -%>. See syntax, examples, output behavior, and common mistakes.

rubyruby-on-railstemplateserb

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.

ruby

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.

rubymacosterminalcompass-sass

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.

rubymacosopensslhomebrew

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.

rubymacosrubygemshomebrew

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.

rubyjsonrubygems

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.

rubyruby-on-railsamazon-web-servicesamazon-s3

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.

rubyfiledirectoryfilenames

Page 1 of 8 - 148 questions

PreviousNext