Class: AdminAssistant::DefaultSearchColumn
- Defined in:
- lib/admin_assistant/default_search_column.rb
Defined Under Namespace
Classes: View
Instance Method Summary collapse
- #add_to_query_condition(ar_query_condition, search) ⇒ Object
- #attributes_for_search_object(search_params, compare_to_range) ⇒ Object
-
#initialize(model_class, opts) ⇒ DefaultSearchColumn
constructor
A new instance of DefaultSearchColumn.
- #search_view(action_view, admin_assistant, opts = {}) ⇒ Object
Methods inherited from Column
#form_view, #index_view, #show_view, #verify_for_search, #view
Constructor Details
#initialize(model_class, opts) ⇒ DefaultSearchColumn
Returns a new instance of DefaultSearchColumn.
3 4 5 6 |
# File 'lib/admin_assistant/default_search_column.rb', line 3 def initialize(model_class, opts) @model_class = model_class @fields_to_match = opts[:fields_to_match] || [] end |
Instance Method Details
#add_to_query_condition(ar_query_condition, search) ⇒ Object
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/admin_assistant/default_search_column.rb', line 8 def add_to_query_condition(ar_query_condition, search) unless search.params.blank? ar_query_condition.ar_query.boolean_join = :and ar_query_condition.boolean_join = :or @fields_to_match.each do |field_name| ar_query_condition.sqls << "LOWER(#{field_name}) like LOWER(?)" ar_query_condition.bind_vars << "%#{search.params}%" end end end |
#attributes_for_search_object(search_params, compare_to_range) ⇒ Object
19 20 21 |
# File 'lib/admin_assistant/default_search_column.rb', line 19 def attributes_for_search_object(search_params, compare_to_range) {} end |