Use StringInquirer for Readable Predicate Methods - Andy Croll

13-Feb-2026 362
You’ve probably seen Rails.env.production? in your codebase to ensure that certain code only runs in production. Instead of having to compare strings, Rails.env == "production", Rails wraps the string in an ActiveSupport::StringInquirer so you get readable methods like .production? and .development?. Active Support also adds an inquiry method to String so you can use this same pattern in your own code.
Use coupon code:

RUBYONRAILS

to get 30% discount on our bundle!
Prepare for your next tech interview with our comprehensive collection of programming interview guides. Covering JavaScript, Ruby on Rails, React, and Python, these highly-rated books offer thousands of essential questions and answers to boost your interview success. Buy our 'Ultimate Job Interview Preparation eBook Bundle' featuring 2200+ questions across multiple languages. Ultimate Job Interview Preparation eBook Bundle