Sha256: df9251206b2aad621c07916e0f3b2faf8e2b1087ec8b73a02f5267feccb9ba23
Contents?: true
Size: 945 Bytes
Versions: 14
Compression:
Stored size: 945 Bytes
Contents
module Admin::Resources::FiltersHelper def build_filters(resource = @resource, params = params) if (typus_filters = resource.typus_filters).any? locals = {} locals[:filters] = typus_filters.map do |key, value| { :key => set_filter(key, value), :value => send("#{value}_filter", key) } end rejections = %w(controller action locale utf8 sort_order order_by) + locals[:filters].map { |f| f[:key] } locals[:hidden_filters] = params.dup.delete_if { |k, v| rejections.include?(k) } render "helpers/admin/resources/filters", locals end end def set_filter(key, value) return key unless value == :belongs_to att_assoc = @resource.reflect_on_association(key.to_sym) class_name = att_assoc.options[:class_name] || key.capitalize.camelize resource = class_name.constantize att_assoc.foreign_key end end
Version data entries
14 entries across 14 versions & 2 rubygems