_form.html.erb (project)

1
2
3
4
5
6
7
<% form_for @project, :html => {:multipart => true} do |f| %>
<div id="photos">
    <%= render :partial => 'photo', :collection => @project.photos %>
</div>
<%= f.submit %>
<% end %>

_photo.html.erb (project)

1
2
3
4
5
6
7
8
9
10
11
<div class="photo">
<table margin="0" padding="0">
<% fields_for "project[photo_attributes][]", photo do |p| %>
  <tr>
    <td width="161"><%= p.label :data, "Afbeelding" %></td>
    <td><%= p.file_field :data, :index => nil %></td>
  </tr>
</table>
<% end %>
</div>

photo model

1
2
3
4
5
6
7
8
9
10
11
class Photo < ActiveRecord::Base
 belongs_to :project

   has_attached_file :data, :styles => {:thumb => "150x112>", :original => "500x400>" }, 
                  :url  => "/images/projects/:id/:style/:basename.:extension",
                  :path => ":rails_root/public/images/projects/:id/:style/:basename.:extension",
                  :default_url => "/images/no_image.gif"


end

update.html.erb (update action is disabled for testing)

1
2
3
4
I've already tried 
<%= debug(params[:project][:photo_attributes] )%>
But this returns 
[{"data"=>#<File:/var/folders/id/idbDI59EHRyIehAeMr-wtE+++TI/-Tmp-/RackMultipart20091204-392-1klw6yd-0>}]