Module: SnFoil::Rails::Searcher
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/snfoil/rails/searcher.rb
Constant Summary collapse
- ASC =
'ASC'
- DESC =
'DESC'
Instance Method Summary collapse
Instance Method Details
#order(params = {}) ⇒ Object
70 71 72 73 74 75 76 77 |
# File 'lib/snfoil/rails/searcher.rb', line 70 def order(params = {}) if params[:order].present? params[:order] = params[:order].to_s.upcase return params[:order] if params[:order].eql?(ASC) || params[:order].eql?(DESC) end self.class.snfoil_order_by_direction || ASC end |
#order_by(params = {}) ⇒ Object
61 62 63 64 65 66 67 68 |
# File 'lib/snfoil/rails/searcher.rb', line 61 def order_by(params = {}) if params[:order_by].present? params[:order_by] = params[:order_by].to_s.underscore return params[:order_by].to_sym if model.attribute_names.include?(params[:order_by]) end self.class.snfoil_order_by_attr || :id end |