Methods
These are the available methods for use in Ruby Views.
Table of Contents
Get data
Example: Get active customers
Method
table
table namecriteria
Add criteria as needed e.g.: school:”fro”, class:”3a”, year:”2001”- if conflict with built in parameters, wrap them in one pair of curly braces {} as parameter 2
fields
comma separated string of fields to retrive, e.g. fields:”first_name, last_name”filter
optional filter with solr syntax. same as tag “filter”rows
default is 20 rows. Increase to improve sorting, or download more files at once. Set ‘MAX_ROWS’ if needed, but check performance when using large values.- Returns empty array [] if no hits
Lookup data
Lookup data in another table. This is similar to using the tag “lookup” in xml
Example: Lookup address_id to find the city
table customers will be updated with the new data
Method
main
existing variable that you want to extend with more dataforeignkey
the foreign key in the main documentprimarykey
the primary key in the lookup tabletable
the lookup table that has more info
Render table
Render the default @docs variable to screen
Render another table than @docs
Use view index and table index if you want to render another table than @docs
You can also send data into the docs variable.
vi
view indexti
table indexprimarykey
comma separated list of primarykeysdocs
optional parameter with data to be rendered
NOTE
If you reorder the xml, you must update the view and table index
Adding extra parameters
Sometimes the next view may need extra data from the previous view. We can add those to the link by sending them into the render table method. Any parameter except of docs will be added to the url.
E.g. here we send info about which view was the previous one, in “from_table”. The name of the variable is your choice.
The next view can check this param