Module: RailsSimpleSearch::SqlHandler
- Defined in:
- lib/sql_handler.rb
Instance Method Summary collapse
Instance Method Details
#init ⇒ Object
3 4 5 6 |
# File 'lib/sql_handler.rb', line 3 def init @model_table_name = @model_class.table_name @joins = {} end |
#run ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/sql_handler.rb', line 8 def run if pre_processor = self.class.pre_processor(@model_class.to_s) instance_eval(&pre_processor) end run_criteria query = @model_class.joins(@joins_str) query = query.where(@condition_group.to_ar_condition) unless @condition_group.empty? query.select("distinct #{@model_class.table_name}.*") end |