plataformatec/devise — pull request #3328 by stephenbaldwin (2014-11-20 20:26:59+00:00)
Title: Ability to load modules in specific order

The order in which third party modules are loaded when mixed in with standard devise modules (or modules included from other sources) is important.

Example:
```ruby
# app/models/user.rb
class User < ActiveRecord::Base
devise :custom_authenticatable, :confirmable
end
```

```ruby
# custom_authenticatable.rb
module Devise
module Models
module CustomAuthenticatable
def active_for_authentication?
true
end
end
end
end

# lib/devise/models/confirmable.rb
module Devise
module Models
module Confirmable
def active_for_authentication?
super && (!confirmation_required? || confirmed? || confirmation_period_valid?)
end
end
end
end
```

Right now Devise automatically adds confirmable, etc in `lib/devise/modules.rb`, and then includes them in the order in which they were added, leaving no way for someone to mix and match modules without manually calling something similar to:
```ruby
Devise::ALL.delete :confirmable
Devise::ALL << :confirmable
# Or
Devise.add_module :custom_authenticatable
Devise.add_module :confirmable
# Devise::ALL => [etc, :confirmable, :custom_authenticatable, :confirmable]
```