Rails Singular/Plural Reference Chart

I’ve begun my descent into pure Rails. The whole naming convention idiom is hard to remember while I’m just learning, so here’s a reference chart for myself and for any other Rails noobs.

# Routes
resources: users

# Controllers
users_controller.rb
class UsersController < ApplicationController
@users = User.all

# Models
user.rb (model)
class User < ActiveRecord::Base

Related Posts:

About the Author:

Joseph is the lead developer of Vert Studios, a web design company located in Tyler, Tx. Follow him on Twitter! @Joe_Query.

  1. Garrett Heinlen

    I think it’s a great idea to make a cheat sheet reference for all those learning. As I am still in the process of trying to learn them myself.

    I noticed you put @users = User.all in the controller which is correct, but that is the naming convention purely for the index action. The others go back to @user = User.find(params[:id]) or whatever, to find a single instance of the user.

    Just thought I’d throw that in, looking forward to seeing this list grow.

    Thanks.

    • You’re right Garrett. I was mainly pointing out to myself that User is singular in the controller. Users.all sounds okay, but is incorrect.

Add to the conversation: