Sha256: e056e252d75fcb498eb8e3275e31831bfc2cf1a55782bf744b1e91799171a22b
Contents?: true
Size: 957 Bytes
Versions: 3
Compression:
Stored size: 957 Bytes
Contents
module Admin::Resources::FiltersHelper def build_filters(resource = @resource, local_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] = local_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
3 entries across 3 versions & 1 rubygems