这是我的 _form.html.erb 中的附件代码
<div class="control-group">
<%= f.label :attachment , :class => 'control-label' %>
<div class="controls">
<%= f.file_field :attachment, :class => 'file_field', multiple: 'true' %>
</div>
</div>
这是我的模型 invoice_details.rb
class InvoiceDetail < ActiveRecord::Base
mount_uploader :attachment, AttachmentUploader
#validates :invoice_number, :supplier_name, :attachment, presence: true # Make sure the owner's name is present.
#validates_uniqueness_of :invoice_number
#validates :invoice_number, length: { maximum: 7 }
#validates :supplier_name, length: { maximum: 20 }
#validates :description_of_goods, length: { maximum: 50 }
#validates :quatity, numericality: true
#validates :price_per_unit, numericality: true
#validates :total_amount, numericality: true
end
这里是另一个模型 invoice_file.rb
class InvoiceFile < ActiveRecord::Base
mount_uploader :attachment, AttachmentUploader # Tells rails to use this uploader for this model.
validates :name, presence: true # Make sure the owner's name is present.
end