File tree Expand file tree Collapse file tree 1 file changed +9
-5
lines changed Expand file tree Collapse file tree 1 file changed +9
-5
lines changed Original file line number Diff line number Diff line change @@ -140,11 +140,7 @@ def check_association_validity(association)
140
140
association . check_validity!
141
141
142
142
if association . options [ :polymorphic ]
143
- entity_name = association . class_name
144
- entity = entity_by_name ( entity_name )
145
- if entity . nil? || entity . generalized?
146
- raise "polymorphic interface #{ entity_name } does not exist"
147
- end
143
+ check_polymorphic_association_validity ( association )
148
144
else
149
145
entity_name = association . klass . name # Raises NameError if the associated class cannot be found.
150
146
entity_by_name ( entity_name ) or raise "model #{ entity_name } exists, but is not included in domain"
@@ -153,6 +149,14 @@ def check_association_validity(association)
153
149
warn "Ignoring invalid association #{ association_description ( association ) } (#{ e . message } )"
154
150
end
155
151
152
+ def check_polymorphic_association_validity ( association )
153
+ entity_name = association . class_name
154
+ entity = entity_by_name ( entity_name )
155
+ if entity . nil? || entity . generalized?
156
+ raise "polymorphic interface #{ entity_name } does not exist"
157
+ end
158
+ end
159
+
156
160
def association_description ( association )
157
161
"#{ association . name . inspect } on #{ association . active_record } "
158
162
end
You can’t perform that action at this time.
0 commit comments