
Security News
Software Engineering Daily Podcast: Feross on AI, Open Source, and Supply Chain Risk
Socket CEO Feross Aboukhadijeh joins Software Engineering Daily to discuss modern software supply chain attacks and rising AI-driven security risks.
require_reloader
Advanced tools
Auto-reload require files or local gems without restarting server
during Rails development.
Currently, it supports Rails 3+ and above, including 3.1 and 3.2.
It uses ActionDispatch::Callbacks.to_prepare to reload the
require files before each request. In Rails 3.2, it uses
watchable_dirs to reload only when you modify a file. More details in this blog post.
Given a Gemfile
# Gemfile
gem 'my_gem', :path => '~/work/my_gem'
gem 'my_gem2', :path => '~/fun/my_gem2', :module_name => 'MYGEM2'
To reload all local gems (the ones with :path attribute,
or using local git repo):
# config/environments/development.rb
YourApp::Application.configure do
...
RequireReloader.watch_local_gems!
end
To reload a specific local gem:
RequireReloader.watch :my_gem
You can also reload a .rb file in lib or any directory:
RequireReloader.watch :half_baked_gem # in lib dir
RequireReloader.watch :foo, :path => 'app/models'
The :path option is optional. In Rails 3.2, :path value is added into watchable_dirs. Rails 3.1 and 3.0 ignore this value.
The :module_name option is optional. By default, it is assumed that the top-level module is a CamelCase version of the gem name.
If this is not the case, you can pass this option, a String. This value will also be picked up if included in the metadata of the gemspec,
as in spec.metadata = {'module_name' => 'MYMOD'}.
RequireReloader adds lib into watchable_dirs. So, specify :path
only if it is not specified in Gemfile and the file is located in other directory.
RequireReloader.watch :foo, :callback => lambda { |gem| puts "#{gem} got reloaded" }
You can supply a Proc with the optional :callback option. This proc gets called everytime after your gem got reloaded.
Add this line to your application's Gemfile:
gem 'require_reloader'
And then execute:
$ bundle
git checkout -b my-new-feature)git commit -am 'Added some feature')git push origin my-new-feature)This gem is forked from Colin Young's gem_reloader, based on a solution by Timothy Cardenas, inspired by a post from Leitch.
FAQs
Unknown package
We found that require_reloader demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Socket CEO Feross Aboukhadijeh joins Software Engineering Daily to discuss modern software supply chain attacks and rising AI-driven security risks.

Security News
GitHub has revoked npm classic tokens for publishing; maintainers must migrate, but OpenJS warns OIDC trusted publishing still has risky gaps for critical projects.

Security News
Rust’s crates.io team is advancing an RFC to add a Security tab that surfaces RustSec vulnerability and unsoundness advisories directly on crate pages.