Sha256: 236edb53d7e8475c05970362cb8789ea6eefc20a5bf171893d5579fc92390daa
Contents?: true
Size: 674 Bytes
Versions: 1
Compression:
Stored size: 674 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 association_filters = ActiveHashRelation::FilterApplier.new( association_name.singularize.constantize.all, params[association], include_associations: true ).apply_filters resource = resource.joins(association).merge(association_filters) end end return resource end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
active_hash_relation-0.0.1 | lib/active_hash_relation/association_filters.rb |