How can I set paperclip's storage mechanism based on the current Rails environment?

后端 未结 7 1359
野性不改
野性不改 2020-12-12 11:07

I have a rails application that has multiple models with paperclip attachments that are all uploaded to S3. This app also has a large test suite that is run quite often. Th

相关标签:
7条回答
  • 2020-12-12 11:37

    Couldn't you just set an environment variable in production/test/development.rb?

    PAPERCLIP_STORAGE_MECHANISM = :s3
    

    Then:

    has_attached_file :image, :styles => {...},
                      :storage => PAPERCLIP_STORAGE_MECHANISM,
                      # ...etc...
    
    0 讨论(0)
提交回复
热议问题