Sce logo

Purpose:

Allow view/download of filtered records from the Survey Documents application.

Method:

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.

Search Terms:

A search term has the following structure:

q[primary_road_cont]=gar
q
Constant designates a search term in the querystring.
[primary_road]
Variable field name to be searched
_cont
Variable Ransack predicate(listed below)
=
Constant designates the target term of the search
gar
Variable target term

or:

q[original_township_or_community_list_cont]=mog
q
Constant designates a search term in the querystring.
[original_township_or_community_list]
Variable field names to be searched
_cont
Variable Ransack predicate (listed below)
=
Constant designates the target term of the search
mog
Variable target term

Sort Term:

A sort term has the following structure:

q[s]=owner
q[s]
Constant designates the sort term in the querystring.
\=
Constant designates the target term of the sort
owner
Variable field name by which the results are to be sorted

Formats:

?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.

Predicates:

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

Fields and Descriptions:

id
the unique identifier (PK) of the record
survey_identifier
Survey department designator of the document
scan_file_name
Survey department file name of the document
scan_page_count
unscanned
Boolean for internal record keeping
original_township
the original township names on the document
quarter
Survey quarters listed on the document
surveyed_on
Date surveyed
acreage
surveyor_number
company_id
the unique id (FK) of the survey company
owner
description
Description of document
primary_road
secondary_road
near_intersection
community_list
tract_list
lot_list
section_list
drawer_location
Paper document location
longitude
longitude of reference indicator
latitude
latitude of reference indicator
easting
Easting (SPC) of reference indicator
northing
Northing (SPC) of reference indicator
created_at
time of creation of record
created_by
creator of record
updated_at
time of most recent update
updated_by
login of most recent update
surveyor_name
Surveyor on document
company_name
Survey Company name on document
communities
combination of original_township and community_list. Useful for avoiding the _or_ in a Ransack predicate
roads
combination of primary_road and secondary_road. Useful for avoiding the _or_ in a Ransack predicate