Module: ActiveScaffold::RecordSelectBridge::SearchColumnHelpers

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

Instance Method Summary collapse

Instance Method Details

#active_scaffold_search_record_select(column, options) ⇒ Object



68
69
70
71
# File 'lib/active_scaffold/bridges/record_select/lib/record_select_bridge.rb', line 68

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



73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/active_scaffold/bridges/record_select/lib/record_select_bridge.rb', line 73

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