4

In my rails app, I have the following nested form fields:

<%= simple_form_for [@page, @section], html: { multipart: true } do |f| %>

    <%= f.simple_fields_for :assets do |asset_fields| %>

        <%= asset_fields.file_field :attachment %>

Now..using:

<%= asset_fields.file_field :attachment %>

this works as expected.. but when I do:

<%= asset_fields.input :attachment, as: :file %>

I get wrong number of arguments (4 for 1) ... what am I missing? I didn't see anything else in the documentation.. The file upload works fine as is; but I would like to use simple form helpers/styles and such.

4
  • I'm sure you have but perhaps just restart your server. Commented Mar 3, 2014 at 20:26
  • have you tried asset_fields.file_field.input ? Commented Mar 3, 2014 at 20:50
  • Hmm restarting it did nothing :/ asset_fields.file_field.input I don't think is correct Stavros, anyhow... it gives me the same error with different numbers of args. Thanks anyways Commented Mar 4, 2014 at 2:00
  • You found the solution ? Commented Aug 31, 2014 at 18:48

1 Answer 1

7

The syntax is little different for file field as follows.

<%= f.simple_fields_for :assets do |asset_fields| %>
    <%= asset_fields.input :attachment, as: :file, input_html: {} %>
<%- end %>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.