Yes. According to strict MVC teachings, this is a bad form and belongs to an assistant.
In theory: this particular piece of functionality is presentation-specific, so, according to the teachings of MVC, it refers to a view helper.
In practice: it really doesn't matter. I believe ActionText is parsed when loading the server / console. This means that the file does not need to be downloaded again. Also, calling a method directly rather than enabling an ActionText is probably better on the part of memory management.
- .
, (model.last_updated) , (last_updated(model)). . , . , - .
, :
module ModelHelper
def included(base)
Model.send(:include, ModelInstanceMethods)
end
module ModelInstanceMethods
def last_updated
updated_at? ? "Updated #{ActionText::time_ago_in_words(updated_at)} ago" : "never updated"
end
end
end
Model - , .