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, ui_options: 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, ui_options: column.options)
  value = field_search_record_select_value(column, options[:value], ui_options: ui_options)
  active_scaffold_record_select(options[:object], column, options.except(:value), value, ui_options[:multiple], ui_options: ui_options)
end

#field_search_record_select_value(column, value, ui_options: column.options) ⇒ 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, ui_options: column.options)
  return if value.blank?
  if ui_options[:multiple]
    column.association.klass.find value.select(&:present?).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