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



69
70
71
72
# File 'lib/active_scaffold/bridges/record_select/helpers.rb', line 69

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

#field_search_record_select_value(column, value) ⇒ Object



74
75
76
77
78
79
80
81
82
83
84
# File 'lib/active_scaffold/bridges/record_select/helpers.rb', line 74

def field_search_record_select_value(column, value)
  return if value.blank?
  if column.options[:multiple]
    column.association.klass.find value.collect!(&:to_i)
  else
    column.association.klass.find(value.to_i)
  end
rescue StandardError => e
  logger.error "#{e.class.name}: #{e.message} -- Sorry, we are not that smart yet. Attempted to restore search values to search fields :#{column.name} in #{controller.class}"
  raise e
end