我覺得一切都很好..但它不工作..
我上傳的GitHub上整個文件
https://github.com/iom00/action2.git
我最近更新寶石。但它在導軌3.2上也有同樣的問題..
Plz help me〜!
一切都很好,但回形針,mongoid多圖片上傳不起作用
組合模型
class Portf
include Mongoid::Document
field :title, type: String
field :decs, type: String
attr_accessible :images
embeds_many :images
accepts_nested_attributes_for :images, :allow_destroy => true
end
圖像模型
class Image
include Mongoid::Document
include Mongoid::Paperclip
field :portf_id, type: Integer
embedded_in :portf , :inverse_of => :images
has_mongoid_attached_file :file
end
組合控制器
# GET /portfs/new
# GET /portfs/new.json
def new
@portf = Portf.new
5.times { @portf.images.build }
respond_to do |format|
format.html # new.html.erb
format.json { render json: @portf }
end
end
# GET /portfs/1/edit
def edit
@portf = Portf.find(params[:id])
5.times { @portf.images.build }
end
形式
<%= form_for @portf, :html => { :multipart => true } do |f| %>
<%= f.fields_for :images do |image| %>
<% if image.object.new_record? %>
<%= image.file_field :file %>
<% end %>
<% end %>
Omg ..非常感謝你!你的天使〜! – user1320189
是否解決了這個問題?!?! – user1320189