Module: ActiveScaffold::Bridges::RecordSelect::Helpers::SearchColumnHelpers

Defined in:
lib/active_scaffold/bridges/record_select/helpers.rb

Instance Method Summary collapse

Instance Method Details

#active_scaffold_search_record_select(column, options) ⇒ Object



61
62
63
64
# File 'lib/active_scaffold/bridges/record_select/helpers.rb', line 61

def active_scaffold_search_record_select(column, options)
  value = field_search_record_select_value(column)
  active_scaffold_record_select(column, options, value, column.options[:multiple])
end

#field_search_record_select_value(column) ⇒ Object



66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/active_scaffold/bridges/record_select/helpers.rb', line 66

def field_search_record_select_value(column)
  begin
    value = field_search_params[column.name]
    unless value.blank?
      if column.options[:multiple]
        column.association.klass.find value.collect!(&:to_i)
      else
        column.association.klass.find(value.to_i)
      end
    end
  rescue Exception => e
    logger.error Time.now.to_s + "Sorry, we are not that smart yet. Attempted to restore search values to search fields but instead got -- #{e.inspect} -- on the ActiveScaffold column = :#{column.name} in #{@controller.class}"
    raise e
  end
end