Learning the conventions

by Rob Kitson


In effort to sharpen the saw a bit I started playing around with Ruby on Rails last week.  I quickly realized a couple things about Convention over Configuration:

  1. How much busy work is avoided by using Conventions, which is probably why certain projects in the .Net and .Net OSS communities are rushing to add Conventions.
  2. One should probably know what the Conventions are before diving into a project that uses them.

So I did a quick google to get a list of the Conventions and found this post on Ruby on Rails Naming Conventions.

Here's the summary of the post, just in case it ever get's taken down.

Model Naming Convention

Table: orders
Class: Order
File: /app/models/order.rb
Primary Key: id
Foreign Key: customer_id
Link Tables: items_orders

Controller Naming Convention

Class: OrdersController
File: /app/controllers/orders_controller.rb
Layout: /app/layouts/orders.html.erb

View Naming Convention

Helper: /app/helpers/orders_helper.rb
Helper Module: OrdersHelper
Views: /app/views/orders/… (list.html.erb for example)

Tests Naming Convention

Unit: /test/unit/order_test.rb
Functional: /test/functional/orders_controller_test.rb
Fixtures: /test/fixtures/orders.yml