Sha256: c1756fff279eef963154cbbcd46999b7decbc70b21ddf2276157169f85de2199

Contents?: true

Size: 1.74 KB

Versions: 22

Compression:

Stored size: 1.74 KB

Contents

module ActiveScaffold::Actions
  module Search
    def self.included(base)
      base.send :include, ActiveScaffold::Actions::CommonSearch
      base.send :include, InstanceMethods
    end

    module InstanceMethods
      protected

      def search_respond_to_html
        render(:action => 'search')
      end

      def search_respond_to_js
        render(:partial => 'search')
      end

      def do_search
        if search_params.is_a?(String) && search_params.present?
          query = search_params.to_s.strip
          columns = active_scaffold_config.search.columns
          text_search = active_scaffold_config.search.text_search
          query = query.split(active_scaffold_config.search.split_terms) if active_scaffold_config.search.split_terms
          search_conditions = self.class.create_conditions_for_columns(query, columns, text_search)
          @filtered = !search_conditions.blank?
          active_scaffold_conditions.concat search_conditions if @filtered

          references, outer_joins = columns.partition { |column| column.includes.present? && list_columns.include?(column) }
          outer_joins.collect!(&:search_joins)
          references.collect!(&:includes)
          active_scaffold_outer_joins.concat outer_joins.flatten.uniq.compact
          active_scaffold_references.concat references.flatten.uniq.compact

          active_scaffold_config.list.user.page = nil
        else
          super
        end
      end

      def search_ignore?
        active_scaffold_config.list.always_show_search && active_scaffold_config.list.search_partial == 'search'
      end

      private

      def search_formats
        (default_formats + active_scaffold_config.formats + active_scaffold_config.search.formats).uniq
      end
    end
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
active_scaffold-3.4.37 lib/active_scaffold/actions/search.rb
active_scaffold-3.4.36 lib/active_scaffold/actions/search.rb
active_scaffold-3.4.35 lib/active_scaffold/actions/search.rb
active_scaffold-3.4.34 lib/active_scaffold/actions/search.rb
active_scaffold-3.4.33 lib/active_scaffold/actions/search.rb
active_scaffold-3.4.32 lib/active_scaffold/actions/search.rb
active_scaffold-3.4.31 lib/active_scaffold/actions/search.rb
active_scaffold-3.4.30 lib/active_scaffold/actions/search.rb
active_scaffold-3.4.29 lib/active_scaffold/actions/search.rb
active_scaffold-3.4.28 lib/active_scaffold/actions/search.rb
active_scaffold-3.4.27 lib/active_scaffold/actions/search.rb
active_scaffold-3.4.26 lib/active_scaffold/actions/search.rb
active_scaffold-3.4.25 lib/active_scaffold/actions/search.rb
active_scaffold-3.4.24 lib/active_scaffold/actions/search.rb
active_scaffold-3.4.23 lib/active_scaffold/actions/search.rb
active_scaffold-3.4.22 lib/active_scaffold/actions/search.rb
active_scaffold-3.4.21.1 lib/active_scaffold/actions/search.rb
active_scaffold-3.4.21 lib/active_scaffold/actions/search.rb
active_scaffold-3.4.20 lib/active_scaffold/actions/search.rb
active_scaffold-3.4.19 lib/active_scaffold/actions/search.rb