• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

mgmodell / devise-multi_email / #122

25 Apr 2026 12:22AM UTC coverage: 98.095% (-0.6%) from 98.73%
#122

push

web-flow
Merge pull request #43 from mgmodell/dependabot/bundler/examples/rails7_app/master/sqlite3-2.9.3

Bump sqlite3 from 2.9.2 to 2.9.3 in /examples/rails7_app

309 of 315 relevant lines covered (98.1%)

31.05 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

95.12
/lib/devise/multi_email.rb
1
require 'devise/multi_email/version'
1✔
2
require 'devise'
1✔
3

4
module Devise
1✔
5
  module MultiEmail
1✔
6
    # Default strategy for password reset emails: :primary or :request.
7
    # :primary (default) sends to the user's primary email address.
8
    # :request sends to the email address used in the forgot-password form.
9
    @password_reset_email_strategy = :primary
1✔
10

11
    class << self
1✔
12
      def configure
1✔
13
        yield self
×
14
      end
15

16
      @autosave_emails = false
1✔
17

18
      def autosave_emails?
1✔
19
        @autosave_emails == true
6✔
20
      end
21

22
      def autosave_emails=(value)
1✔
23
        @autosave_emails = (value == true)
7✔
24
      end
25

26
      @only_login_with_primary_email = false
1✔
27

28
      def only_login_with_primary_email?
1✔
29
        @only_login_with_primary_email == true
2✔
30
      end
31

32
      def only_login_with_primary_email=(value)
1✔
33
        @only_login_with_primary_email = (value == true)
1✔
34
      end
35

36
      # Controls which address receives password reset emails by default.
37
      # Accepts :primary (default) or :request.
38
      # :primary — always send to the user's primary email.
39
      # :request — send to the email address the user entered in the forgot-password form.
40
      # This default can be overridden per call via the email: keyword on
41
      # send_reset_password_instructions_notification.
42

43
      def password_reset_email_strategy
1✔
44
        @password_reset_email_strategy
1✔
45
      end
46

47
      def password_reset_email_strategy=(value)
1✔
48
        value = value.try(:to_sym)
1✔
49
        if value == :request
1✔
50
          @password_reset_email_strategy = :request
1✔
51
        else
52
          @password_reset_email_strategy = :primary
×
53
        end
54
      end
55

56
      def parent_association_name
1✔
57
        @parent_association_name ||= :user
9✔
58
      end
59

60
      def parent_association_name=(name)
1✔
61
        @parent_association_name = name.try(:to_sym) unless '' == name
7✔
62
      end
63

64
      def emails_association_name
1✔
65
        @emails_association_name ||= :emails
3✔
66
      end
67

68
      def emails_association_name=(name)
1✔
69
        @emails_association_name = name.try(:to_sym) unless '' == name
1✔
70
      end
71

72
      def primary_email_method_name
1✔
73
        @primary_email_method_name ||= :primary_email_record
1✔
74
      end
75

76
      def primary_email_method_name=(name)
1✔
77
        @primary_email_method_name = name.try(:to_sym) unless '' == name
1✔
78
      end
79
    end
80
  end
81
end
82

83
# Register multi_email modules right after their standard Devise counterparts in Devise::ALL.
84
# This ensures they are always processed before third-party extensions such as
85
# devise-encryptable, regardless of gem load order in the Gemfile. The sort in
86
# Devise::Models#devise uses Devise::ALL ordering when including modules, so a lower
87
# index here guarantees the base module (e.g. database_authenticatable) is included
88
# before any override module (e.g. encryptable), preserving the correct MRO.
89
Devise.add_module :multi_email_authenticatable,
1✔
90
                  model: 'devise/multi_email/models/authenticatable',
91
                  insert_at: Devise::ALL.index(:database_authenticatable).to_i + 1
92
Devise.add_module :multi_email_confirmable,
1✔
93
                  model: 'devise/multi_email/models/confirmable',
94
                  insert_at: Devise::ALL.index(:confirmable).to_i + 1
95
Devise.add_module :multi_email_recoverable,
1✔
96
                  model: 'devise/multi_email/models/recoverable',
97
                  insert_at: Devise::ALL.index(:recoverable).to_i + 1
98
Devise.add_module :multi_email_validatable,
1✔
99
                  model: 'devise/multi_email/models/validatable',
100
                  insert_at: Devise::ALL.index(:validatable).to_i + 1
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc