Skip to content

Commit

Permalink
Use ActiveSupport.on_load to hook into Active Record and Mongoid.
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasmazza committed Jun 27, 2016
1 parent 92bb772 commit c2c74b0
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
* Remove the `Devise::Models::Recoverable#after_password_reset` method.
* bug fixes
* Fix an `ActionDispatch::IllegalStateError` when testing controllers with Rails 5 rc 2(by @hamadata).
* Use `ActiveSupport.on_load` hooks to include Devise on `ActiveRecord` and `Mongoid`,
avoiding autoloading these constants too soon (by @lucasmazza, @rafaelfranca).
* enhancements
* Display the minimum password length on `registrations/edit` view (by @Yanchek99).
* You can disable Devise's routes reloading on boot by through the `reload_routes = false` config.
Expand Down
4 changes: 3 additions & 1 deletion lib/devise/orm/active_record.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
require 'orm_adapter/adapters/active_record'

ActiveRecord::Base.extend Devise::Models
ActiveSupport.on_load(:active_record) do
extend Devise::Models
end
6 changes: 4 additions & 2 deletions lib/devise/orm/mongoid.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
require 'orm_adapter/adapters/mongoid'
ActiveSupport.on_load(:mongoid) do
require 'orm_adapter/adapters/mongoid'

Mongoid::Document::ClassMethods.send :include, Devise::Models
Mongoid::Document::ClassMethods.send :include, Devise::Models
end

0 comments on commit c2c74b0

Please sign in to comment.