-
-
Save naveda89/033ee723e43468ec7e78 to your computer and use it in GitHub Desktop.
This file contains 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
# For finding images as in Article.attachments.images | |
scope :with_images, proc { |attachment| where('?_content_type LIKE ?', attachment, 'image%') } | |
# For finding other files Article.attachments.docs | |
scope :with_docs, proc { |attachment| where('?_content_type NOT LIKE ?', attachment, 'image%') } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Scope now can receive the attachment type.
Usage: Model.with_images('avatar')
or Model.with_docs('manuals')