Skip to content

Commit 9d66563

Browse files
author
James McKinney
committed
Do not assume that a #foo_id method implies a #foo method (fixes @daxter's regression in 600b539)
1 parent cc5577c commit 9d66563

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

lib/active_admin/views/components/attributes_table.rb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,13 @@ def content_for(attr)
5656
end
5757

5858
def find_attr_value(attr)
59-
attr.is_a?(Proc) ? attr.call(@record) : @record.send(attr.to_s.gsub(/_id\z/,''))
59+
if attr.is_a?(Proc)
60+
attr.call(@record)
61+
elsif attr.to_s[/\A(.+)_id\z/] && @record.respond_to?($1.to_sym)
62+
@record.send($1.to_sym)
63+
else
64+
@record.send(attr.to_sym)
65+
end
6066
end
6167
end
6268

0 commit comments

Comments
 (0)