Module: AdministrateRansack::Searchable
- Defined in:
- lib/administrate_ransack/searchable.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.prepended(base) ⇒ Object
24 25 26 |
# File 'lib/administrate_ransack/searchable.rb', line 24 def prepended(base) base.helper_method :sanitized_order_params end |
Instance Method Details
#sanitized_order_params(page, current_field_name) ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/administrate_ransack/searchable.rb', line 15 def sanitized_order_params(page, current_field_name) collection_names = page.item_associations + [current_field_name] association_params = collection_names.map do |assoc_name| { assoc_name => %i[order direction page per_page] } end params.permit(:search, :id, :page, :per_page, association_params, q: {}) end |
#scoped_resource ⇒ Object
7 8 9 10 11 12 |
# File 'lib/administrate_ransack/searchable.rb', line 7 def scoped_resource = respond_to?(:ransack_options, true) ? : {} distinct = respond_to?(:ransack_result_distinct, true) ? ransack_result_distinct : true @ransack_results = prepare_search(resource_collection: super, query_params: params[:q], options: ) @ransack_results.result(distinct: distinct) end |