model missing required attr_accessor for 'photo_file_name' when uploading with paperclip and S3 on heroku

前端 未结 3 841
温柔的废话
温柔的废话 2020-12-10 05:20

Setting up paperclip with S3 in my linux dev environment was a snap -- everything works out of the box. However, I can\'t get it to work on Heroku.

When I try to do

相关标签:
3条回答
  • 2020-12-10 05:37

    Well, this message seems to be because the columns it's missing. Try create a migration creating the columns:

    class AddPhotoToEvent < ActiveRecord::Migration
      def change
        add_column :events, :photo_file_name,    :string
        add_column :events, :photo_content_type, :string
        add_column :events, :photo_file_size,    :integer
        add_column :events, :photo_updated_at,   :datetime
      end
    

    end

    This work for me, here i have a table events with photo

    0 讨论(0)
  • 2020-12-10 05:46

    Error like this occurs if you create wrong column type in migration. When you define new table migration for paperclip, you need to specify t.attachment :name insted of t.string :name. Or add_attachment :table, :name when you add new paperclip column in existed table. And now you don't need to add these attributes in attr_accessor in model.

    0 讨论(0)
  • 2020-12-10 05:47

    Found the problem: needed to update the database.

    heroku run rake:db:migrate

    heroku restart

    I had done what I thought would have accomplished the same thing already:

    heroku rake db:schema:load

    but perhaps that doesn't work or something went wrong in the process.

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