vendor/plugins/active_scaffold/lib/active_scaffold/finder.rb
# Generates an SQL condition for the given ActiveScaffold column based on
# that column's database type (or form_ui ... for virtual columns?).
# TODO: this should reside on the column, not the controller
Generates an SQL condition for the given ActiveScaffold column based on
that column's database type (or form_ui ... for virtual columns?).
TODO: this should reside on the column, not the controller
Generates an SQL condition for the given ActiveScaffold column based on that column ' s database type ( or form_ui ... for virtual columns? ) . TODO : this should reside on the column not the controller
def condition_for_column(column, value, text_search = :full)
        like_pattern = like_pattern(text_search)
        return unless column and column.search_sql and not value.blank?
        search_ui = column.search_ui || column.column.type
        if self.respond_to?("condition_for_#{column.name}_column")
          self.send("condition_for_#{column.name}_column", column, value, like_pattern)
        elsif self.respond_to?("condition_for_#{search_ui}_type")
          self.send("condition_for_#{search_ui}_type", column, value, like_pattern)
        else
          case search_ui
            when :boolean, :checkbox
            ["#{column.search_sql} = ?", column.column.type_cast(value)]
            when :select
            ["#{column.search_sql} = ?", value[:id]] unless value[:id].blank?
            when :multi_select
            ["#{column.search_sql} in (?)", value.values.collect{|hash| hash[:id]}]
            else
              if column.column.nil? || column.column.text?
                ["LOWER(#{column.search_sql}) LIKE ?", like_pattern.sub('?', value.downcase)]
              else
                ["#{column.search_sql} = ?", column.column.type_cast(value)]
              end
          end
        end
      end
def condition_for_column ( column , value , text_search = :full ) like_pattern = like_pattern ( text_search ) return unless column and column . search_sql and not value . blank? search_ui = column . search_ui || column . column . type if self . respond_to? ( "condition_for_#{column.name}_column" ) self . send ( "condition_for_#{column.name}_column" , column , value , like_pattern ) elsif self . respond_to? ( "condition_for_#{search_ui}_type" ) self . send ( "condition_for_#{search_ui}_type" , column , value , like_pattern ) else case search_ui when :boolean , :checkbox [ "#{column.search_sql} = ?" , column . column . type_cast ( value ) ] when :select [ "#{column.search_sql} = ?" , value [ :id ] ] unless value [ :id ] . blank? when :multi_select [ "#{column.search_sql} in (?)" , value . values . collect { | hash | hash [ :id ] } ] else if column . column . nil? || column . column . text? [ "LOWER(#{column.search_sql}) LIKE ?" , like_pattern . sub ( '?' , value . downcase ) ] else [ "#{column.search_sql} = ?" , column . column . type_cast ( value ) ] end end end end
Generates an SQL condition for the given ActiveScaffold column based on
that column's database type (or form_ui ... for virtual columns?).
Generates an SQL condition for the given ActiveScaffold column based on that column ' s database type ( or form_ui ... for virtual columns? ) .
# we must check false or not blank because we want to search for false but false is blank
column
<not_specific>
value
<not_specific>
text_search
<not_specific>