def conditions_from_constraints
      hash_conditions = {}
      conditions = [hash_conditions]
      active_scaffold_constraints.each do |k, v|
        column = active_scaffold_config.columns[k]
        if column
          # Assume this is a multi-level association constraint.
          # example:
          #   data model: Park -> Den -> Bear
          #   constraint: :den => {:park => 5}
          if params_hash? v
            far_association = column.association.klass.reflect_on_association(v.keys.first)
            field = far_association.klass.primary_key
            table = far_association.table_name

            active_scaffold_references.concat([{k => far_association.name}]) # e.g. {:den => :park}
            hash_conditions.deep_merge!(table => {field => v.values.first})

          # association column constraint
          elsif column.association
            join_from_association_constraint(column)
            hash_conditions.deep_merge!(condition_from_association_constraint(column.association, v))

          # regular column constraints
          elsif column.searchable? && params[column.name] != v
            active_scaffold_references.concat column.references if column.includes.present?
            conditions << [column.search_sql.collect { |search_sql| "#{search_sql} = ?" }.join(' OR '), *([v] * column.search_sql.size)]
          end
        # unknown-to-activescaffold-but-real-database-column constraint
        elsif active_scaffold_config.model.columns_hash[k.to_s] && params[column.name] != v
          hash_conditions.deep_merge!(k => v)
        else
          raise ActiveScaffold::MalformedConstraint, constraint_error(active_scaffold_config.model, k), caller
        end
      end
      conditions.reject(&:blank?)
    end
def conditions_from_constraints
      hash_conditions = {}
      conditions = [hash_conditions]
      active_scaffold_constraints.each do |k, v|
        column = active_scaffold_config.columns[k]
        if column
          # Assume this is a multi-level association constraint.
          # example:
          #   data model: Park -> Den -> Bear
          #   constraint: :den => {:park => 5}
          if params_hash? v
            far_association = column.association.klass.reflect_on_association(v.keys.first)
            field = far_association.klass.primary_key
            table = far_association.table_name

            active_scaffold_references.concat([{k => far_association.name}]) # e.g. {:den => :park}
            hash_conditions.deep_merge!(table => {field => v.values.first})

          # association column constraint
          elsif column.association
            join_from_association_constraint(column)
            hash_conditions.deep_merge!(condition_from_association_constraint(column.association, v))

          # regular column constraints
          elsif column.searchable? && params[column.name] != v
            active_scaffold_references.concat column.references if column.includes.present?
            conditions << [column.search_sql.collect { |search_sql| "#{search_sql} = ?" }.join(' OR '), *([v] * column.search_sql.size)]
          end
        # unknown-to-activescaffold-but-real-database-column constraint
        elsif active_scaffold_config.model.columns_hash[k.to_s] && params[column.name] != v
          hash_conditions.deep_merge!(k => v)
        else
          raise ActiveScaffold::MalformedConstraint, constraint_error(active_scaffold_config.model, k), caller
        end
      end
      conditions.reject(&:blank?)
    end
Returns search conditions based on the current scaffold constraints.

 Supports constraints based on either a column name (in which case it checks for an association
 or just uses the search_sql) or a database field name.

 All of this work is primarily to support nested scaffolds in a manner generally useful for other
 embedded scaffolds.