Sha256: c16c5d21f5e9050520db00339b8e8176dd4dac602edad71d546056e3c580712a

Contents?: true

Size: 516 Bytes

Versions: 8

Compression:

Stored size: 516 Bytes

Contents

module Outpost
  module Controller
    module Filtering
      private

      def filter_records
        if params[:filter].is_a? Hash
          params[:filter].each do |attribute, value|
            next if value.blank?
            scope = "filtered_by_#{attribute}"

            if @records.klass.respond_to? scope
              @records = @records.send(scope, value)
            else
              @records = @records.where(attribute => value)
            end
          end
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
outpost-cms-0.1.4 lib/outpost/controller/filtering.rb
outpost-cms-0.1.3 lib/outpost/controller/filtering.rb
outpost-cms-0.1.2 lib/outpost/controller/filtering.rb
outpost-cms-0.1.1 lib/outpost/controller/filtering.rb
outpost-cms-0.1.0 lib/outpost/controller/filtering.rb
outpost-cms-0.0.5 lib/outpost/controller/filtering.rb
outpost-cms-0.0.4 lib/outpost/controller/filtering.rb
outpost-cms-0.0.3 lib/outpost/controller/filtering.rb