Rails Naming Convention

March 16th, 2009 . Posted in general.

Sometime I feel confusing when getting a switch back to code from one language to one language. From PHP to Javascript to ActionScript3 and RubyOnRails, I was confusing the style to code in each language sometime, especially with naming conventions. So, here’s a quick note of naming convention in Rails

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

hope not to confuse again :-/
Technorati Tags: , ,

Leave a Reply