Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the naming rule behind Rails' parts?

Some Rails' parts start with "Active":

  • ActiveRecord
  • ActiveModel
  • ActiveSupport

And some Rails' parts start with "Action":

  • ActionPack
  • ActionView
  • ActionMailer

Why is that? Why don't they all have the same prefix? And what do "Active" and "Action" mean in this context?

DHH is now building "ActiveJob", and how did he know if it wasn't supposed to be "ActionJob"?

like image 514
janko-m Avatar asked May 19 '14 21:05

janko-m


People also ask

What is the naming convention in Rails?

Naming conventions in Active Record model Rails is capable of pluralizing (and singularizing) both regular and irregular words. Model class names must use the CamelCase form when composed of two or more words, while the database table names must use the snake_case form.

Should controllers be plural Rails?

If the controller is a resource then it must be plural... Show activity on this post. The naming convention of controllers in Rails favors pluralization of the last word in the controller's name, although it is not strictly required (e.g. ApplicationController ).


2 Answers

The way I look at it, again this is just my perspective (the only person who can give a confirmed answer is DHH :) ),

When I see Action* like ActionPack (ActionView and ActionController are the two major components of ActionPack) or ActionMailer, they pertain to an action performed within the Rails application be it a controller specific action or displaying a particular view or even sending an email. So, Action seems precise prefix here as these packages denote doing something.

When I see Active* like ActiveRecord, ActiveSupport or ActiveModel etc., it somehow relates to providing some useful functionality to your Rails applications business logic be it utility methods or ORM support kind of like add-ons to facilitate the Rails application development.

Hope to see more interesting answers on this question. This is where we can start analyzing.

like image 124
Kirti Thorat Avatar answered Oct 21 '22 08:10

Kirti Thorat


Action* is for user facing stuff (views, controllers, mailers) and Active* are backend components that supports the Action* components

like image 37
Cristian Bica Avatar answered Oct 21 '22 06:10

Cristian Bica