We were using helper methods inside the model; we might as well include them in the model and use them from anywhere else. Note we're using a different logic for images and documents methods. That's because for images the logic was defined in the helper methods, but for documents the logic is defined in the Documentable concern. In the past, different documentable classes allowed different content types, while imageable classes have always allowed the same content types. I'm not sure which method is better; for now, I'm leaving it the way it was (except for the fact that we're removing the helper methods).
6 lines
134 B
Ruby
6 lines
134 B
Ruby
module ImageablesHelper
|
|
def can_destroy_image?(imageable)
|
|
imageable.image.present? && can?(:destroy, imageable.image)
|
|
end
|
|
end
|