Naming Convention is always a good practice to use suggestive variable names, Class and Module name, Database table, Module and Controllers name that will assist in the documentation of a Ruby on Rails program. A good convention for variable names, Class and Module name, Database table, Module and Controllers name can often assist someone in better understanding the operation of a program module or script. So it is important to understand the naming convention for Ruby on Rails as in other programming language.
In this post I tried to explain how Variables, Class and Module, Database Table, Model etc. are defined in Ruby on Rails.
Variables: Variables are named where all letters are lowercase and words are separated by underscores. E.g: total, order_amount.
Class and Module: Classes and modules uses MixedCase or CamelCase and have no underscores, each word starts with a uppercase letter. Eg: InvoiceItem
Database Table: Table name have all lowercase letters and underscores between words, also all table names to be plural. Eg: invoice_items, orders etc
Model: The model is named using the class naming convention of unbroken MixedCase and always the singular of the table name. For eg: table name is might be orders, the model name would be Order. Rails will then look for the class definition in a file called order.rb in /app/model directory. If the model class name has multiple capitalized words, the table name is assumed to have underscores between these words.
Controller: controller class names are pluralized, such that OrdersController would be the controller class for the orders table. Rails will then look for the class definition in a file called orders_controlles.rb in the /app/controller directory.
Model Naming Convention
Foreign key: customer_id
Link Table: items_orders
Controller Naming Convention
Helper Naming Convention
Helper Module: OrdersHelper
Views: /app/view/orders/…(list.html.erb for example)
Test Naming Convention