File tree Expand file tree Collapse file tree 1 file changed +9
-3
lines changed
activerecord/lib/active_record Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change 3
3
module ActiveRecord
4
4
class AssociationNotFoundError < ConfigurationError #:nodoc:
5
5
attr_reader :record , :association_name
6
+
6
7
def initialize ( record = nil , association_name = nil )
7
8
@record = record
8
9
@association_name = association_name
@@ -17,16 +18,21 @@ def initialize(record = nil, association_name = nil)
17
18
include DidYouMean ::Correctable
18
19
19
20
def corrections
20
- @corrections ||= begin
21
- maybe_these = record &.class &.reflections &.keys
22
- DidYouMean ::SpellChecker . new ( dictionary : maybe_these ) . correct ( association_name . to_s )
21
+ if record && association_name
22
+ @corrections ||= begin
23
+ maybe_these = record . class . reflections . keys
24
+ DidYouMean ::SpellChecker . new ( dictionary : maybe_these ) . correct ( association_name )
25
+ end
26
+ else
27
+ [ ]
23
28
end
24
29
end
25
30
end
26
31
end
27
32
28
33
class InverseOfAssociationNotFoundError < ActiveRecordError #:nodoc:
29
34
attr_reader :reflection , :associated_class
35
+
30
36
def initialize ( reflection = nil , associated_class = nil )
31
37
if reflection
32
38
@reflection = reflection
You can’t perform that action at this time.
0 commit comments