Paperclip Error: model missing required attr_accessor for 'avatar_file_name'

前端 未结 3 2034
陌清茗
陌清茗 2020-12-18 21:08

I then want to use Paperclip to have photos for each Listing. I added the appropriate code to the listings show.html.erb, the listing.rb model, the listings_controller.rb an

3条回答
  •  庸人自扰
    2020-12-18 21:19

    From the error message, file_name is not available in the model to which you're trying to save. I had a similar problem and realized I forgot to run the Paperclip migration:

    rails generate paperclip [Model Name] [Attachment] (e.g., rails g paperclip Images image)

    If that doesn't work, since the issue it's having is column "file_name", try adding that to the model (e.g. rails g migration addFilenameToImages file_name:string)

    This worked for me, so hopefully it helps some of you too!

提交回复
热议问题