Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix "config.enabled" not working #35

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

alhajrahmoun
Copy link

This is a proposed fix for #26.

The RailsLiveReload.enabled? check is currently performed immediately when the Railtie class is interpreted, returning true since it's the default value. However, due to the Rails application lifecycle, the state of RailsLiveReload.enabled? will change by the time the initializers are run and it will return the value specified in the rails app initializer.

I tried moving the RailsLiveReload.enabled? check into each initializer block and it seems to be fixing the issue.

@@ -1,7 +1,11 @@
module RailsLiveReload
class Railtie < ::Rails::Engine
if RailsLiveReload.enabled? && (defined?(::Rails::Server) || ENV['SERVER_PROCESS'])
initializer "rails_live_reload.middleware" do |app|
def enabled?
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

enabled can probably be changed into something more meaningful. Open to suggestions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant