Take the 2-minute tour ×

Ok just to get this out of the way I dont need anything fancy just to be able to list 5 file fields for uploading images. Currently, I receive no errors when visiting the form but the form file upload inputs aren't being display where the rest of the form is rendering properly.

Things I have working so far:

  • s3 with paperclip
  • Upload single files

With that said Ill post portions of the models to give a better picture of my setup:

My product model:

has_many :photos
attr_accessible :name, :description, :price, :category_id, :location_ids
accepts_nested_attributes_for :photos, :allow_destroy => true

My photo model:

belongs_to :products
attr_accessible :image,
has_attached_file :image, styles: {
  thumb: '100x100>',
  square: '200x200#',
  medium: '300x300>'

My product controller:

def new
  @product = Product.new
  5.times { @product.photos.build }

My product post form:

<%= simple_form_for @product,
:url => admin_products_path  do |form| %>
<% form.simple_fields_for :photos do |builder| %>
  <% if builder.object.new_record? %>
    <%= builder.input :image %>
  <% end %>
<% end %>
<% end %>

I tried to keep this as simple as possible since this is my first implementation. Most of the documentation online was for a little bit older rails but I attempted to make it work with rails 3.2.1, paperclip, simple_forms_for, aws-sdk.

Please help :D

share|improve this question
add comment

1 Answer

up vote 0 down vote accepted

I believe you need to use the erb output syntax for the simple_fields_for nested attributes helper:

<%= form.simple_fields_for :photos do |builder| %>
# ^ ...
share|improve this answer
Thank you so much! Ive been staring at the code so long I wouldve never seen that! –  battlemidget Feb 3 '13 at 5:04
We all need a second set of eyes sometimes. –  rossta Feb 3 '13 at 5:07
add comment

Your Answer


