paperclip working in development but not working in production?

前端 未结 2 708
夕颜
夕颜 2021-01-02 22:00

I\'m pretty new to rails and seem to be having an issue with the paperclip gem. I installed the gem and it works well in development (localhost:3000) but when I\'m running i

相关标签:
2条回答
  • 2021-01-02 22:09

    You could be having a few problems. However, the first is that you can not write to the file system on Heroku. You will have to implement a different storage mechanism such as s3. You can read about this limitation here: http://devcenter.heroku.com/articles/read-only-filesystem

    0 讨论(0)
  • 2021-01-02 22:36

    In your model.

    has_attached_file :picture, 
                       :styles => {:large => "275x450>"},
                       :storage => :s3, 
                       :s3_credentials => "#{RAILS_ROOT}/config/s3.yml",
                       :path => "appname/:attachment/:style/:id.:extension"
    

    In s3.yml in your config dir:

        development:
          bucket: bucketname
          access_key_id: key
          secret_access_key: key
    
        production:
          bucket: bucketname
          access_key_id: key
          secret_access_key: key
    

    Then go signup for a bucket at Amazon S3: http://aws.amazon.com/s3/

    0 讨论(0)
提交回复
热议问题