Allow view/download of filtered records from the Monuments application.
The primary method of filtering is by adding Search Terms, an optional Sort Term, and a Format Specification to the URL.
For example:
/monuments.xml?q[horz_order_cont]=fir&q[usgs_quad_cont]=rich
Return all records where the horz_order contains 'fir' and the usgs_quad contains 'rich', in xml format.
OR
/monuments.json?q[vert_order_or_horz_order_cont]=thir&q[s]=pid
Return all records where the vert_order or horz_order contain 'thir', sorted by PID, in json format.
A search term has the following structure:
q[horz_order_cont]=fir
or:
q[vert_order_or_horz_order_cont]=thir
A sort term has the following structure:
q[s]=pid
?format=xml OR /monuments.xml?{query string}Three formats are supported: xls, xml, and json. Xls format triggers download of an Excel-format file with the search results.
Ransack predicates are used to determine what information to match. For instance, an "vert_order_cont" predicate will return all records where an attribute called "vert_order" contains a value using a wildcard query: The SQL equivalent of [vert_order_cont]=firs is
SELECT "monuments".* FROM "monuments" WHERE("monuments"."vert_order" LIKE '%firs%')
You can also combine predicates for OR queries:
The SQL equivalent of [vert_or_horz_order_cont]=thir is
SELECT "monuments".* FROM "monuments" WHERE("monuments"."vert_order" LIKE '%thir%' OR "monuments"."horz_order" LIKE '%thir%')
Below is a table of predicates and their opposites.
Predicate | Meaning | Opposite |
---|---|---|
eq | The eq predicate returns all records where a field is exactly equal to a given value: | not_eq |
matches | The matches predicate returns all records where a field is like a given value. *Note: If you want to do wildcard matching, you may be looking for the cont/not_cont predicates instead. | does_not_match |
lt (less than) | The lt predicate returns all records where a field is less than a given value | gteq (greater than or equal to) |
in | The in predicate returns all records where a field is within a specified list | not_in |
cont | The cont predicate returns all records where a field contains a given value | not_cont |
cont_any (contains any) | The cont_any predicate returns all records where a field contains any of given values | not_cont_any |
start (starts with) | The start predicate returns all records where a field begins with a given value | not_start |
end (ends with) | The end predicate returns all records where a field ends with a given value | not_end |
true | The true predicate returns all records where a field is true. The "1" indicates that to Ransack that you indeed want to check the truthiness of this field. The other truthy values are 'true', 'TRUE', 't' or 'T'. | false |
present | The present predicate returns all records where a field is present (not null and not a blank string). | blank |
null | The null predicate returns all records where a field is null | not_null |