Sha256: d2cfdf5f582b752902fbd0ce7d93c4559d4a637fd41bcc55bfd7d955e098b7ae
Contents?: true
Size: 1.53 KB
Versions: 3
Compression:
Stored size: 1.53 KB
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 if self.configuration.use_unscoped association_filters = self.filter_class(association_name).new( association_name.singularize.constantize.unscoped.all, params[association] ).apply_filters else association_filters = self.filter_class(association_name).new( association_name.singularize.constantize.all, params[association] ).apply_filters end else if self.configuration.use_unscoped association_filters = ActiveHashRelation::FilterApplier.new( association_name.singularize.constantize.unscoped.all, params[association], include_associations: true ).apply_filters else association_filters = ActiveHashRelation::FilterApplier.new( association_name.singularize.constantize.all, params[association], include_associations: true ).apply_filters end end resource = resource.joins(association).merge(association_filters) end end return resource end end
Version data entries
3 entries across 3 versions & 1 rubygems