Forum: Rails France Comment uploader plusieurs photos a la fois avec Paperclip?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
E01b1ddbf8cb213cd55c9899f254d8e3?d=identicon&s=25 Chaochito (Guest)
on 2008-12-09 21:00
(Received via mailing list)
Bonjour,

Je suis developpeur junior ruby on rails et je suis coince depuis
quelque temps par l'upload de plusieurs photos a la fois a partir d'un
formulaire avec paperclip.

Comment uploader plusieurs photos a la fois avec paperclip

Voila mes modeles:

class Photo < ActiveRecord::Base

  belongs_to :gallery

  has_attached_file :celeb_photo,
                    :styles => { :original => '1024x1024',:medium =>
"300x300>", :thumb => "100x100>" },
                    :url =>
"/:attachment/:id/:style/:basename.:extension",
                    :path => ":rails_root/
public/:attachment/:id/:style/:basename.:extension"

end


class Gallery < ActiveRecord::Base

  has_many :photos

end


Les vues me causent un casse tete pas possible:

<div id="gallery_new_form">


  <div id="gallery_information">
    <% form_for @gallery, :html => { :multipart => true } do |f| -%>

      <h3>Upload a Gallery</h3>

      <div id="photo_1">
      <% fields_for @photo, :html => { :multipart => true } do |
celebrity_photo| %>
          <%= celebrity_photo.label 'Upload Photo 1' %>
        <%= celebrity_photo.file_field :celeb_photo %>
      <% end %>
      </div>
      <div id="photo_2">
      <% fields_for @photo, :html => { :multipart => true } do |
celebrity_photo| %>
          <%= celebrity_photo.label 'Upload Photo 2' %>
          <%= celebrity_photo.file_field :celeb_photo %>
      <% end %>
      </div>
      <div id="photo_3">
      <% fields_for @photo, :html => { :multipart => true } do |
celebrity_photo| %>
          <%= celebrity_photo.label 'Upload Photo 3' %>
          <%= celebrity_photo.file_field :celeb_photo %>
      <% end %>
      </div>
      <div id="photo_4">
      <% fields_for @photo, :html => { :multipart => true } do |
celebrity_photo| %>
        <%= celebrity_photo.label 'Upload Photo 4' %>
          <%= celebrity_photo.file_field :celeb_photo %>
      <% end %>
      </div>
      <div id="photo_5">
      <% fields_for @photo, :html => { :multipart => true } do |
celebrity_photo| %>
          <%= celebrity_photo.label 'Upload Photo 5' %>
        <%= celebrity_photo.file_field :celeb_photo %>
      <% end %>
      </div>

      <h3>Gallery Information</h3>

      <%= f.label :name, 'Gallery Name' %>
      <%= f.text_field :name, :size => 10  %><br />

      <%= f.label :celebrity_name, 'Celebrity Name' %>
      <%= f.text_field :celebrity_name, :size => 10  %><br />

      <%= f.label :description, 'Description' %>
      <%= f.text_area :description, :cols => 10, :rows => 10 %>
<br />



      <%= submit_tag 'Upload' %>
   <% end -%>
  </div> <%# general_information -%>

</div> <%# galleries_new_form %>

Comment faire la liaison entre les photos et la gallerie dans les
views et
comment sauver la gallerie ainsi que les photos dans le controlleur?
Aussi qu'est ce que je dois ecrire dans le form_for et les fields_for.



Merci d'avance,
This topic is locked and can not be replied to.