There is nothing wrong with a constructor, simply because they are almost never needed. The main reason for the constructor is to set default values. Setting attributes by default is easy at the database level
add_column :users, :admin, :boolean, :default => false
. Another important thing that may be required is the creation / creation of an association model, this can be done either in the constructor / initializer, but in that it is more common to use rail hooks to set before_create :populate_children, :ensure_parent_exists (where populate_children and secure_parent_exists are private methods of the model) or something like that. This approach means that any initialization logic can be divided into logical methods (for example, separate methods for each initialization bit), and some can be additionally called at other times after_save :ensure_parent_exists and, thus, provide greater flexibility
source share