Created
August 13, 2019 17:10
-
-
Save mrsweaters/b8afac69ad25fd884f9f3c74f455060c to your computer and use it in GitHub Desktop.
Get organic samples and backfill from constants.
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
def self.sample_text(attr, scope: self, size: 3) | |
@organic = scope.last(size).map{|item| ActionController::Base.helpers.strip_tags(item.public_send(attr)) }.compact | |
defaults = "#{scope}::SAMPLE_#{attr.upcase}".constantize | |
(@organic + defaults).uniq.first(size) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment