Created
December 19, 2016 13:09
-
-
Save thiagoa/40194e3335cb6b4cae0dc4c89649419f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Imageable | |
# When including this module, this hook is called | |
# by Ruby with the included module/class | |
def self.included(model_class) | |
model_class.has_many :images | |
end | |
def main_image | |
images.find { |image| image.kind == 'main_image' } | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment