Skip to content

Commit 54378b0

Browse files
committed
fix to catch error when it retrieves polymorphic association
closes #113
1 parent 8db2aa5 commit 54378b0

File tree

2 files changed

+2
-3
lines changed

2 files changed

+2
-3
lines changed

lib/comma/header_extractor.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def get_association_class(model_class, association)
4545

4646
begin
4747
model_class.reflect_on_association(association)&.klass
48-
rescue NameError
48+
rescue ArgumentError
4949
nil
5050
end
5151
end

spec/comma/rails/active_record_spec.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,7 @@ def name
144144

145145
describe 'github pull-request 83' do
146146
it 'should not raise NameError' do
147-
expect { Picture.all.to_comma(:pr_83) }
148-
.not_to raise_exception(NameError)
147+
expect { Picture.all.to_comma(:pr_83) }.not_to raise_error
149148
end
150149
end
151150
end

0 commit comments

Comments
 (0)