I am working on a rails project, using Carrierwave for uploading files and images. I just need a way to count number of files uploaded to server via carrierwave. Something like AvatarUploader.all.count
?
Thanks.
I am working on a rails project, using Carrierwave for uploading files and images. I just need a way to count number of files uploaded to server via carrierwave. Something like AvatarUploader.all.count
?
Thanks.
If there is a Model A, make a has_many association to Model A_attachments that gets created for each attachment and simply count them by A_attachments.count.
For counting the number of models in record, you just need ModelName.count and that's it.
There's a really detailed explanation from a user named SSR in this link https://stackoverflow.com/a/21412174
I don't want to copy and paste the answer because he really deserves an upvote for this.