Looking for some assistance/advice on effectively using ActiveStorage. I’ve been operating with older Rails for years, just recently coming up to speed with Rails 6 and loving most things. The power of ActiveStorage is clear, but its usage beyond basic cases is confounding me. The docs are very sparse on details for a ActiveStorage beginner like myself. For example, we’re shown how to easily add custom analyzers (DOCXAnalyzer
), but where’s the example implementation of it?
I’ve got a very basic tool I’m building to process CSVs, I successfully created a CSVAnalyzer and had the analyzer job invoking my metadata job. Great! But now what? I need to download and process the CSV (I can do that), and create child records (related to the parent of the blob) … this is where I hit a wall. I must’ve been missing something obvious here, because I don’t care about returning metadata for my CSV, I just want to process it. Is this a valid use-case for ActiveStorage + Custom Analyzer? Or am I better with a traditional job that runs after the CSV is attached?
Skeleton of custom analyzer for reference
require 'activestorage/analyzer'
class CSVAnalyzer < ActiveStorage::Analyzer
def self.accept?(blob)
blob.content_type == 'text/csv'
end
def metadata
{}
end
end
Appreciate the time