2

I have a form like this :

<%= simple_form_for @user, remote: true do |f| %>
  <%= f.input :email %>
  <%= f.input :photo, as: :attachinary %>
  <%= f.button :submit %>
<% end %>

My controller looks like this :

  def update
    if @user.update(user_params)
      respond_to do |format|
        format.html { redirect_to user_path(@user) }
        format.js
      end
    else
      respond_to do |format|
        format.html { render 'users/edit' }
        format.js
      end
    end
  end

It works good with the HTML version but not with javascript version.

I know that browsers don't allow file upload via XMLHttpRequest, so I find a solution with remotipart gem, but it only considers <%= f.file_field :file %> and not my <%= f.input :photo, as: :attachinary %>

0 Answers0