Ruby

http://s.erious.ly

Posts tagged "models"

Annotate Your Models

One of the primary functions of any ORM (e.g. Active::Record) is to provide all those neat little “ghost” methods to manipulate your persistent data.  The problem is that ghosts are invisible.  It can be frustrating to open a model file and see nothing about the model’s attributes.  For Active::Record the solution is the annotate gem. sudo...

Sending email: Controllers versus Models

While reviewing some code recently, I came across controller code that resembled the following.

if @customer.save
  CustomerMailer.deliver_welcome_message(@customer)
  flash[:message] = "Your account has been successfully created. We've sent you a welcome letter with..."
  redirect_to dashboard_path
else
  ...
end

Fairly typical Rails code. Nothing alarming here, but I wanted to evaluate the call to the mailer in...