Right now what it does is allows me to select files but I need to click an additional “Submit” button to do the form submission. Is it possible to combine the functionality of the browse button with form submission? Is there functionality within Rails or do I need to create a custom ajax call using javascript? Thanks!
Current code:
= form_for @user, :url => add_file(@user), :remote => true do |f|
= file_field_tag :file
Rails does not have such functionality.
You will need to write javascript to do this, but you do not need to make an ajax call.
Instead, define the file_field_tag but make it hidden with CSS display:none;. Then define a button which implements your javascript. Your javascript should call the hidden file_field_tag, and then submit the form.
Sorry to not write this in HAML, but I leave that to you. 🙂