Skip to content

Commit

Permalink
fix: Patch to make Devise compatible with Rails 8
Browse files Browse the repository at this point in the history
  • Loading branch information
mishina2228 committed Dec 14, 2024
1 parent 6a17063 commit 2962fe0
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions config/initializers/devise_rails8_patch.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# frozen_string_literal: true

# Delete this patch when https://github.com/heartcombo/devise/pull/5728 is released.

require 'devise'
raise 'Devise is not yet available' unless defined? Devise # make sure it's already loaded

module Devise
def self.mappings
# Starting from Rails 8.0, routes are lazy-loaded by default in test and development environments.
# However, Devise's mappings are built during the routes loading phase.
# To ensure it works correctly, we need to load the routes first before accessing @@mappings.
Rails.application.try(:reload_routes_unless_loaded)
@@mappings
end
end

0 comments on commit 2962fe0

Please sign in to comment.