Get rid of deprecation error by writing cleaner code

It was spitting errors looking like this:

DEPRECATION WARNING: The method `attachment_type', matching the
attribute `attachment_type' has dispatched through method_missing. This
shouldn't happen, because `attachment_type' is a column of the table. If
this error has happened through normal usage of Active Record (rather
than through your own code or external libraries), please report it as a
bug.