Convention is to use the plural form of the model name when applicable, e.g. stories controller, authors controller
Action Controller and Helper methods are named where all letters are lowercase and words are separated by underscores, e.g. list_all, textilize
Private methods start with an underscore.
Singular, first letter Capitalized, CamelCase for models like SteeringWheel
Validation of data is here.
Model files have information in them which appears like belongs_to and has_many and reflects automatic connections made by Akelos, using fields like author_id in a story table
Plurality matters. Be very careful – Akelos does stuff with making this singular and plural again, so make sure you are including the appropriate number of s
How things look - Akelos in html ⇒ tpl
<?= link_to($product->name, 'action' => 'show', 'id' => $product->id ?>
Table names need to be plural, with underscores instead of spaces between words, like steering_wheels, invoice_items, orders.
Akelos handles creation date/time and update date/time out of the box, so there is no need to code it yourself. Handling dates and searching through ranges might be tricky, if you use the Akelos conventions this comes for free.
By convention if you add a column named “created_at” or “updated_at” it will handle those fields for you automatically and if you name a column in a migration like “posted_at” it will set the field type and length for you, in this case, datetime. If you use “created_on” it will use just “date”.
Akelos natively supports the following column data types:
Caution: Because boolean is virtual tinyint on mysql, you can't use tinyint for other things!
| column_name | default setting | usage |
|---|---|---|
| id | integer not null auto_increment primary_key | Primary key |
| *_id,*_by | integer index | Foreign key |
| description,content,body | text | |
| position | integer index | |
| *_count | integer default 0 | |
| lock_version | integer default 1 | |
| *_at | datetime | created_at, updated_at,… |
| *_on | date | starts_on, ends_on,… |
| is_*,has_*,do_*,does_*,are_* | boolean not null default 0 index | |
| *somename | multilingual column ⇒ en_somename, es_somename | |
| default | string |
The primary key of a table is assumed to be named id.
The foreign key is named with the singular version of the target table name with _id appended to it, e.g. order_id in the items table where we have items linked to the orders table.
Tables used to join two tables in a many to many relationship is named using the table names they link, with the table names in alphabetical order, for example items_orders.
You can get ActiveRecord to automatically update the create and update times of records in a database table. To do this create two specially named columns created_at and updated_at to your table. If you only want to store the date rather than a date and time, use created_on and updated_on.
Classes use MixedCase and have no underscores, each word starts with a uppercase letter, e.g. InvoiceItem
Files are named using lowercase and underscores. Assuming we have an Orders controller then the following other conventions will apply: