Sha256: 4e7f886009644c51f702eb3f746490099b6431558f17ca9b77474b9b64ae4433
Contents?: true
Size: 836 Bytes
Versions: 3
Compression:
Stored size: 836 Bytes
Contents
# Adapter for the `ransack` gem. class RESTFramework::RansackFilter < RESTFramework::BaseFilter # Filter data according to the request query parameters. def get_filtered_data(data) q = @controller.request.query_parameters[@controller.ransack_query_param] if q.present? distinct = @controller.ransack_distinct # Determine if `distinct` is determined by query param. if distinct_query_param = @controller.ransack_distinct_query_param distinct_from_query = ActiveRecord::Type::Boolean.new.cast( @controller.request.query_parameters[distinct_query_param], ) unless distinct_from_query.nil? distinct = distinct_from_query end end return data.ransack(q, @controller.ransack_options).result(distinct: distinct) end return data end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
rest_framework-0.9.5 | lib/rest_framework/filters/ransack.rb |
rest_framework-0.9.4 | lib/rest_framework/filters/ransack.rb |
rest_framework-0.9.3 | lib/rest_framework/filters/ransack.rb |