RailsCasts Pro episodes are now free!

Learn more or hide this

yoavbo's Profile

GitHub User: yoavbo

Comments by


Does anyone know how to change the file_field when dealing with nested attributes? The main table is users. each has_many images. The application works fine for uploading a single file (using carrierwave).

<%= f.fields_for :images do |z| %>
    <%= z.label :image_title %><br />
    <%= z.text_field :image_title %>
    <%= z.hidden_field :image_priority, :value => '1' %> 
    <%= z.file_field :image_location %>
<% end %>

The railscast says you should add a "multiple" option to file_Field and then "hardcode" the field name. So somthing like this:

<%= z.file_field :image_location, multiple: true, name: "images[image_location]" %>