Ruby on Rails, Paperclip, Amazon AWS S3 & Heroku

前端 未结 3 1085
-上瘾入骨i
-上瘾入骨i 2020-12-30 16:08

I try for two days to make my all web site work on the internet through Heroku and Amazon AWS S3 ( to store my images ) but ... I can\'t make it !

To make it simpli

3条回答
  •  伪装坚强ぢ
    2020-12-30 16:49

    Can you post your Photo class?

    From the logs

    Paperclip::Error (Photo model missing required attr_accessor for 'image_file_name'):
    

    It looks to me like you don't have the has_attached_file defined on your class.

    From the tutorial you linked:

    class Friend < ActiveRecord::Base
      # You will need to use attr_accessible if you are
      # using Rails config setting `whitelist_attributes = true`
      attr_accessible :avatar
    
      # This method associates the attribute ":avatar" with a file attachment
      has_attached_file :avatar, styles: {
        thumb: '100x100>',
        square: '200x200#',
        medium: '300x300>'
     }
    end
    

    If you do have this (or something similar) then you probably need to make a migration to get that column in your database:

    add_attachment :photos, :image
    

    Which will add the correct columns to your photos table.

    With the has_attached_file and the columns on your table, I don't think you should have any (or at least the same) problems

提交回复
热议问题