DISQUS

Pete On Rails: Adding Multiple Attachements to a Model in one View

  • John · 1 year ago
    Does the fields_for block work in this instance with af.file_field because you used javascript to create multiple upload fields? Without javascript, would you be stuck using file_field_tag to upload multiple files using attachment fu, and as a result not being able to use the fields_for block?

    Thank you!,
    John
  • John · 1 year ago
    ...continued to from last post...

    ...as a result not being able to use the fields_for block?...thereby not being able to use one field to work with two models?
  • John · 1 year ago
    ...edit from last post...

    ...as a result not being able to use the fields_for block?...thereby not being able to use one FORM to work with two models?
  • peteonrails · 1 year ago
    No, it'll work without javascript if you expect that in your application. Instead of having this line of code produce a javascript enabled link that dynamically inserts a new file_field box:

    <%= add_attachment_link "Add a File" %>

    You can instead have it post the form and return to the edit view with another empty file_field box.

    It should still work with af.file_field.

    Do you have an example of code that isn't working? If so, point me to it and I'll take a look.