Sha256: 67897e94349c79da3a86afb24f5e2860f67bf1db09f227a6617783073815d7c2

Contents?: true

Size: 593 Bytes

Versions: 4

Compression:

Stored size: 593 Bytes

Contents

module Para
  module SearchHelper
    def fulltext_search_param_for(attributes)
      "#{ searchable_attributes(attributes) }_cont"
    end

    def filtered?(attributes)
      params[:q] && params[:q][fulltext_search_param_for(attributes)].present?
    end

    def searchable_attributes(attributes)
      whitelist = attributes.select do |attribute|
        [:string, :text].include?(attribute.type.to_sym) &&
          !attribute.name.match(/password/)
      end

      whitelist.map do |attribute|
        attribute.attribute_column_path.join('_')
      end.join('_or_')
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
para-0.5.3 app/helpers/para/search_helper.rb
para-0.5.1 app/helpers/para/search_helper.rb
para-0.5.0 app/helpers/para/search_helper.rb
para-0.4.0 app/helpers/para/search_helper.rb