Class: Might::RansackableSort
- Inherits:
-
Object
- Object
- Might::RansackableSort
- Defined in:
- lib/might/ransackable_sort.rb
Overview
Sort scope
Instance Method Summary collapse
-
#call(env) ⇒ <ActiveRecord::Relation, <String>]
<ActiveRecord::Relation, <String>].
-
#initialize(app) ⇒ RansackableSort
constructor
A new instance of RansackableSort.
Constructor Details
#initialize(app) ⇒ RansackableSort
Returns a new instance of RansackableSort.
6 7 8 |
# File 'lib/might/ransackable_sort.rb', line 6 def initialize(app) @app = app end |
Instance Method Details
#call(env) ⇒ <ActiveRecord::Relation, <String>]
Returns <ActiveRecord::Relation, <String>].
15 16 17 18 19 20 21 22 |
# File 'lib/might/ransackable_sort.rb', line 15 def call(env) scope, params = env ransackable_query = scope.ransack ransackable_query.sorts = params[:sort] app.call([ransackable_query.result, params]) end |