1

Paperclip を使用して複数のファイルをアップロードしていますが、それらを表示できません。ここに私がしようとしているものがあります:

モデル:

class Attach < ActiveRecord::Base
  attr_accessible :protocol_id, :file

  has_attached_file :file,
   :path => ':rails_root/public/system/attachs/files/000/000/0:id/original/:basename.:extension'
  attr_accessible :file_file_name, :file_content_type, :file_file_size
  validates_attachment_presence :file

  belongs_to :protocol
end

class Protocol < ActiveRecord::Base
  attr_accessible :current_approved, :p_irb_apn, :past_approved, :attachs_attributes
  has_many :attachs
  accepts_nested_attributes_for :attachs, :allow_destroy => true
end

私のコントローラーの一部:

  def new
    @protocol = Protocol.new
    @protocol.attachs.build

    respond_to do |format|
      format.html # new.html.erb
      format.json { render json: @protocol }
    end
  end

画像を保存するフォームの一部:

  <div class="field"> 
    <%= f.label :file, "Mod" %>
    <%= file_field_tag('protocol_attachs_attributes_file', multiple: true, name: "protocol[attachs_attributes][][file]") %> 
  </div>

そして私のショー:

<p>
  <b>Modification:</b>
  <% for attach in @protocol.attachs %> 
    <%= link_to "Download", @protocol.attachs.url(:original)%>
  <% end %>
</p>

アップロードするたびに、同じファイルを何度も取得しています (別のファイルであっても)。誰でもこの問題について私を助けることができますか?

4

1 に答える 1