8000 Use foreign_key · activeadmin/activeadmin-mongoid@38c227a · GitHub
[go: up one dir, main page]

Skip to content

Commit 38c227a

Browse files
Use foreign_key
1 parent 90538e9 commit 38c227a

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

lib/active_admin/mongoid/association/relatable.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,9 @@ def macro
66
def embeds?
77
[:embeds_one, :embeds_many].include?(macro)
88
end
9+
10+
def foreign_key
11+
return if embeds?
12+
foreign_key.to_sym rescue nil
13+
end
914
end

lib/active_admin/mongoid/filters/resource_extension.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ def default_association_filters
66
without_embedded = resource_class.reflect_on_all_associations.reject { |e| e.embeds? }
77
poly, not_poly = without_embedded.partition{ |r| r.macro == :belongs_to && r.options[:polymorphic] }
88

9-
filters = poly.map(&:foreign_type) + not_poly.map(&:name)
9+
filters = poly.map(&:foreign_key) + not_poly.map(&:name)
1010
filters.map &:to_sym
1111
else
1212
[]

0 commit comments

Comments
 (0)
0