Ruby on rails 附件不包括';t填写编辑表格
Rails 4.2.1、Ruby 2.2.1和PostgreSQL 9.3 我有Ruby on rails 附件不包括';t填写编辑表格,ruby-on-rails,paperclip,simple-form,cocoon-gem,Ruby On Rails,Paperclip,Simple Form,Cocoon Gem,Rails 4.2.1、Ruby 2.2.1和PostgreSQL 9.3 我有地区和模式模型 class Region < ActiveRecord::Base has_many :patterns, dependent: :destroy accepts_nested_attributes_for :patterns, reject_if: :all_blank, allow_destroy: true end class Pattern < ActiveRecord:
地区
和模式
模型
class Region < ActiveRecord::Base
has_many :patterns, dependent: :destroy
accepts_nested_attributes_for :patterns, reject_if: :all_blank, allow_destroy: true
end
class Pattern < ActiveRecord::Base
belongs_to :region
has_attached_file :picture
validates_attachment_content_type :picture, content_type: "image/png"
end
\u pattern\u fields.html.slim
查看
.nested-fields
.form-inline
= f.input :picture, as: :file
= link_to_remove_association f, class: 'btn btn-default btn-xs' do
.glyphicon.glyphicon-remove
我可以轻松创建具有多个图案的区域,但当我单击“编辑”时,文件字段为空
有没有好方法可以正确使用回形针处理文件字段和rails表单?在创建图像时,您是否检查了数据库中的图像是否被存储并与区域/图案关联?@Deep是的。在schema.rb模式表中有
region\u id
列
.nested-fields
.form-inline
= f.input :picture, as: :file
= link_to_remove_association f, class: 'btn btn-default btn-xs' do
.glyphicon.glyphicon-remove