Hi all I have a form which contains attachments but the attachment is not getting created in file system and the fields for the attachment in DB is not getting filled when a new form is created .
I'm using paperclip
I hope the problem is with view part html=>:multipart (as I'm using a single form to create multiple instances)
My Controller:
def create @ins=params[:ins].values.collect{|ins|InsPol.new(ins)} respond_to do |format| if @ins.all?(&:valid?) @ins.each(&:save!)
format.html { redirect_to :action => 'index'} else
format.html {render :action => 'new'}
end end
def new @ins = Array.new(3.times){InsPol.new} end
My view:
<%= form_tag({:action => :create}, {:multipart => true}) %> <% @ins.each_with_index do |ins, index| %> <% fields_for "ins[#{index}]", ins do |f| %> <%= f.text_field :pol_number%> <%= f.file_field :attachment%> <% end %> <br/> <% end %> <%= submit_tag "Save"%> </form>
My Model:
class InsPol < ActiveRecord::Base has_attached_file :attachment
end
Moreover i have All the db migration for this attachment using paperclip and paperclip installed properly
Plz help me in this regard