I'm trying to figure out how to send the model value to the custom Paperclip processor, and just can't figure out why it is so complicated or what the solution may be, since I'm trying to solve it for a few days later ... Here is my code extracted from my model and processor.
From my model:
... has_attached_file :receipt_file, :storage => :s3, :s3_credentials => "#{Rails.root}/config/s3.yml", :path => "/:style/:id/:filename", :s3_protocol => "https", :styles => { :text => { style: :original, receipt_id: self.id }}, processors: [:LearnProcessor] ...
Why can't I use "self.id" to get the receipt id? How is it that "/:style/:id/:filename" translates into something like /original/1/abc.pdf , and if I put receipt_id: :id , all I get from options[:receipt_id] (see below) is :id instead of 1 ?
Do I need some kind of interpolation?
Processor code
module Paperclip class LearnProcessor < Processor attr_accessor :receipt_id,:style def initialize(file, options = {}, attachment = nil) @file = file @current_format = File.extname(@file.path) @basename = File.basename(@file.path, @current_format) @style = options[:style] @receipt_id = options[:receipt_id] puts "Options #{options.inspect}" end ...
source share