Posted about 2 years ago. Visible to the public. Repeats.

Don't require files in random order

A common pattern in Ruby is to to require all files in a specific diretory, using something like

Copy
Dir.glob(Rails.root.join('lib/ext/**/*.rb')).each do |filename| require filename end

However, this causes files to be required in an order determined by the file system. Since load order can be important, this may lead to different behavior on different machines which are hard to debug.

Simply add a .sort:

Copy
Dir.glob(Rails.root.join('lib/ext/**/*.rb')).sort.each do |filename| require filename end

Does your version of Ruby on Rails still receive security updates?
Rails LTS provides security patches for old versions of Ruby on Rails (3.2 and 2.3).

Owner of this card:

Avatar
Tobias Kraze
Last edit:
about 2 years ago
by Arne Hartherz
About this deck:
We are makandra and do test-driven, agile Ruby on Rails software development.
License for source code
Posted by Tobias Kraze to makandra dev
This website uses cookies to improve usability and analyze traffic.
Accept or learn more