I’ve been trying to experiment with having avatars for users in my app, and I’ve set this up where a user can upload an image using Paperclip. Paperclip has a nice default functionality where you can define a placeholder image when the user has not uploaded an image. What I’m wondering is, is there any way to create a set of placeholder images and have paperclip choose one at random when the associated record is created? IE so not all the “no avatar” icons have to be identical?
Thanks!
My best guess for how to accomplish this would be to “override” how you access your avatar images.
Maybe something along the following:
This way you can use one interface to access the existing avatar or a randomly chosen one from your views. You don’t want to use
random_avatar_urldirectly from your views, so maybe private or protect it to make sure others know.