newbie seek for help about paperclippolymorph

Hi All,
I am new to rails and I need to upload multiple images with paperclippolymorph , I have a model “scene” like this:

 class Scene < ActiveRecord::Base
    belongs_to :user
    acts_as_polymorphic_paperclip
   #  accepts_nested_attributes_for :assets, :allow_destroy => true
 end

 And the controller  and view :

 class ScenesController < ApplicationController
     
     def create
         @scene = Scene.new(params[:scene])
         respond_to do |format|
            if @scene.save

               # bla bla ..
            else
               #  bla bla
            end
         end
     end

 end

 #view:
    <% form_for(@scene, :html => { :multipart => true }) do |f| %>

          <%= f.file_field :data %>  <!-- it's just a single file field, how to enable multiple upload? -->
          <%= f.submit "submit" %>
    <% end %>

  I can upload single image successfully but don't know how to upload multiple, my question is how can I upload multiple image at once? I have tried with fields_for like following and it failed,  does anyone have idea?

<% form_for(@scene, :html => { :multipart => true }) do |f| %>
<% f.fields_for :assets do |asset_field| %>
<%= asset_field.file_field :data %>
<%= asset_field.file_field :data %>
<% end %>
<% end %>

    Any advice is appreciated, thanks

    Regards

Hi there,

I’m not a longtime Rails developper so pardon me if misunderstood your pb.

But IMHO, I believe you’re looking for a solution to enable multiple records creation through one form.

Why don’t you have a look at this short video:

http://railscasts.com/episodes/73-complex-forms-part-1

and probably part 2 or 3 as well,

Anyway, it helped me to sort out a rather similar problem

Hope this helps,

Christophe

thank you Christophe, it’s really helpful, and it works for me.