Skip to content

Commit

Permalink
Merge pull request #127 from 3mundi/remove_embedded_filters
Browse files Browse the repository at this point in the history
Avoid to create filters for embedded fields
  • Loading branch information
grzegorz-jakubiak authored Aug 23, 2018
2 parents 018812e + d8a35d6 commit 884b5b0
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/active_admin/mongoid/filters/resource_extension.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
module ActiveAdmin::Filters::ResourceExtension
def default_association_filters
if resource_class.respond_to?(:reflect_on_all_associations)
poly, not_poly = resource_class.reflect_on_all_associations.partition{ |r| r.macro == :belongs_to && r.options[:polymorphic] }
without_embedded = resource_class.reflect_on_all_associations.reject { |e| [:embeds_many, :embeds_one].include? e.macro }
poly, not_poly = without_embedded.partition{ |r| r.macro == :belongs_to && r.options[:polymorphic] }

filters = poly.map(&:foreign_type) + not_poly.map(&:name)
filters.map &:to_sym
Expand Down

0 comments on commit 884b5b0

Please sign in to comment.