Code naming conventions used on the site (for editors)
Last edited about 4 years ago — Added over 4 years ago

AntCat's code is written in the Ruby programming language, using the framework Ruby on Rails (or just "Rails").

Nerdy words often appear in code blocks, like Name, names and names.name, to make it easier to see what kind of "name" that is being referred to.

Rails conventions
What Format Example
Database table names Plural, lower case, words separated by underscores history_items
Database column/field names Often prefixed with the table name; "column" and "field" can generally be used interchangeably protonym_id or history_items.protonym_id
Rails models Singular, first letters in words capitalized, no spaces HistoryItem


Database vs. Rails models

The database can be said to be more "stupid": it often knows how tables and columns are connected to other tables and columns via foreign keys (this is however not always the case), but it knows less about the domain model.

Rails models usually map 1-to-1 to a database table with the pluralized name of the model. They are responsible most domain knowledge, for example which Taxon statuses (column taxa.status) are required to have a "Current taxon" (taxa.current_taxon_id).