Sce logo

Purpose:

Allow view/download of filtered records from the 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:

/documents.xml?q[subdivision_name_cont]=or&q[plat_book_cont]=2
Return all records where the subdivision_name contains 'or' and the plat_book contains '2', in xml format.

OR

/documents.json?q[plat_book_or_subdivision_name_cont]=2&q[s]=dated_on
Return all records where the plat_book or subdivision_name contain '2', sorted by dated_on, in json format.

Search Terms:

A search term has the following structure:

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

or:

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

Sort Term:

A sort term has the following structure:

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

Formats:

?format=xml OR /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 "plat_book_cont" predicate will return all records where an attribute called "plat_book" contains a value using a wildcard query: The SQL equivalent of [plat_book_cont]=2 is

SELECT "documents".* FROM "documents" WHERE("documents"."plat_book" LIKE '%2%')

You can also combine predicates for OR queries:

The SQL equivalent of [vert_or_subdivision_name_cont]=2 is

SELECT "documents".* FROM "documents" WHERE("documents"."plat_book" LIKE '%2%' OR "documents"."subdivision_name" LIKE '%2%')

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
ID
subdivision_name
Subdivision Name
document_type
Document Type
latitude
Latitude
longitude
Longitude
dated_on
Date
spc_e_ft
Easting (ft)
spc_n_ft
Northing (ft)
spc_e_meters
Easting (m)
spc_n_meters
Northing (m)
plat_reception_number
Plat Reception Number
plat_book
Plat Book
plat_book_page_range
Plat Book Page Range
plat_cabinet
Plat Cabinet
plat_cabinet_slide_range
Plat Cabinet Slide Range
location
Location
created_at
created_by
images_zip_file_name
images_zip_file_size
images_zip_content_type
images_zip_updated_at
is_unzipped
is_image_processed
updated_by
updated_at