0

在启用舒适的应用程序中的自定义模型中没有得到任何结果。我有一个模型,它有一个 Comfortable Mexican Sofa 后端,它包含一个要上传到 AWS 的文件。有一个桶,我已经配置了各个点:

aws.yml:

development:
  access_key_id: 'xxxxxxxxx'
  secret_access_key: 'xxxxxxxxx'

开发.rb:

config.paperclip_defaults = {
  :storage => :s3,
  :bucket => 'somerton'
}

模型(绘图.rb):

has_attached_file :image

validates_attachment_content_type :image, content_type: /\Aimage\/.*\Z/

我使用回形针生成器生成了模型,架构是

架构.rb:

create_table "drawings", force: :cascade do |t|
  t.string   "url"
  t.string   "title"
  t.string   "description"
  t.datetime "created_at"
  t.datetime "updated_at"
  t.string   "image_file_name"
  t.string   "image_content_type"
  t.integer  "image_file_size"
  t.datetime "image_updated_at"
end

部分表单已修改为包含文件输入,并且是多部分的:

_form.html.haml:

= form.text_field :url
= form.text_field :title
= form.text_field :description
= form.file_field :image

= form.form_group :class => 'form-actions' do
  = form.submit :class => 'btn btn-primary'

有人看到我缺少的明显问题吗?(是的,gem 已安装):

gem "paperclip", "~> 4.3" # uploads
gem 'aws-sdk' # allow use of aws for upload storage

当我更新一条记录时,我可以使用文件输入选择一个文件,但相关组件的列是空的:

--- !ruby/object:Drawing
raw_attributes:
id: 1
url: blah blah
title: My new thing
description: Dog's Breakfast
created_at: '2015-10-15 20:02:03.848104'
updated_at: '2015-10-15 20:02:33.344581'
image_file_name: 
image_content_type: 
image_file_size: 
image_updated_at: 
...
4

0 回答 0