Joe Masilotti

@joemasilotti

Website GitHub X

TIL about beginless and endless ranges in Ruby

TIL about beginless/endless ranges in Ruby 2.7 which can be used to clean up Active Record queries!

# Users with an ID less than or equal to 200.
User.where("id <= ?", 200)
User.where(id: ..200)

# Users with an ID less than 200.
User.where("id < ?", 200)
User.where(id: ...200)

# Users with an ID greater than or equal to 200.
User.where("id >= ?", 200)
User.where(id: 200..)

Regarding privacy concerns, it's simple - we don't sell your data. In fact, we try to use privacy-focused software/services like Fathom Analytics whenever we use any third-party services.