Allow view/download of filtered records from the Survey Documents application.
The primary method of filtering is by adding Search Terms, an optional Sort Term, and a Format Specification to the URL.
For example:
/survey_documents.xml?q[primary_road_cont]=gar&q[easting_gte]=2220000
Return all records where the primary_road contains 'gar' and the easting is greater than or equal to 2220000, in xml format.
OR
/survey_documents.json?q[original_township_or_community_list_cont]=mog&q[s]=owner
Return all records where the original_township or community_list contain 'mog', sorted by owner, in json format.
A search term has the following structure:
q[primary_road_cont]=gar
or:
q[original_township_or_community_list_cont]=mog
A sort term has the following structure:
q[s]=owner
?format=xml OR /survey_documents.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 "owner_cont" predicate will return all records where an attribute called "owner" cont ains a value using a wildcard query: The SQL equivalent of [owner_cont]=Rya is
SELECT "documents".* FROM "documents" WHERE("documents"."owner" LIKE '%Rya%')
You can also combine predicates for OR queries:
The SQL equivalent of [original_township_or_community_list_cont]=mog is
SELECT "documents".* FROM "documents" WHERE("documents"."original_township" LIKE '%mog%' OR "documents"."community_list" LIKE '%Rya%')
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 |