Sha256: 80db726581f822aafe94f80dc6301edec65006ae5bfb577c72e60a6df99f51fa
Contents?: true
Size: 998 Bytes
Versions: 4
Compression:
Stored size: 998 Bytes
Contents
module ActiveHashRelation::AssociationFilters def filter_associations(resource, params, model: nil) unless model model = model_class_name(resource) end model.reflect_on_all_associations.map(&:name).each do |association| if params[association] association_name = association.to_s.titleize.split.join if self.configuration.has_filter_classes puts self.filter_class(association_name) association_filters = self.filter_class(association_name).new( association_name.singularize.constantize.all, params[association] ).apply_filters else association_filters = ActiveHashRelation::FilterApplier.new( association_name.singularize.constantize.all, params[association], include_associations: true ).apply_filters end resource = resource.joins(association).merge(association_filters) end end return resource end end
Version data entries
4 entries across 4 versions & 1 rubygems