Sign in through GitHub

RailsCasts Pro episodes are now free!

Learn more or hide this

krishna varma's Profile

GitHub User: buddaraju

Comments by krishna varma


how to upload multiple files using carrierwave
i am using carrierwave gem for file upload. It is working fine with single upload, but how to upload multiple files please help me.

This is my form:

<%= form_for(@invoice_detail , html: {class: 'form-horizontal', role: 'form' }) do |f| %>
 <div class="field">
        <%= f.label :invoice_number, :class => 'control-label' %>
            <div class="controls">
    <%= f.text_field :invoice_number, :class => 'text_field', :required => true, :maxlength => 15, :placeholder =>'15 Alpha Numeric with special Characters', :presence => "check invoice num"   %>
  <div class="control-group">
      <%= f.label :attachment, :multiple => true , :class => 'control-label' %>
      <div class="controls">
        <%= f.file_field :attachment, :class => 'file_field', :required => true %>
    <div class="form-actions1">
    <%= f.submit  :class => 'btn btn-primary' %>
    <%#= f.submit "cancel", :class => 'btn btn-danger', method: :delete, data: { confirm: 'Are you sure you want to cancel' } %>
    <%= link_to "Cancel", invoice_details_path(), :class => 'btn btn-danger', data: { confirm: 'Are you sure you want to cancel' } %>

<% end %>


class AttachmentUploader < CarrierWave::Uploader::Base

  storage :file

  def store_dir
  def extension_white_list
    %w(xlsx pdf doc htm html docx png jpg jpeg xls)

  def filename
  "#{model.invoice_number}.#{file.extension}" if original_filename.present?


I used for refernce.