RailsCasts Pro episodes are now free!
Learn more or hide this
GitHub User: yoavbo
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).
views/users/new.html.erb <%= f.fields_for :images do |z| %> <fieldset> <p> <%= z.label :image_title %><br /> <%= z.text_field :image_title %> <%= z.hidden_field :image_priority, :value => '1' %> </p> <p> <%= z.file_field :image_location %> </p> </fieldset> <% 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]" %>
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).
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]" %>