JangoSteve / remotipart

Rails jQuery file uploads via standard Rails "remote: true" forms.
http://os.alfajango.com/remotipart
Other
1k stars 215 forks source link

When I add "//= require jquery.remotipart" my [:image] field is not even in params #152

Closed ghost closed 8 years ago

ghost commented 8 years ago

I have Rails 5, and ruby 2.3.1. I have already done a project with Carrierwave and remotipart and it was working perfectly. But now, for a incredibly weird reason whenever I add //= require jquery.remotipart to application.js, the :image field from my form is not in the passing params. I am using

gem 'remotipart', github: 'mshibuya/remotipart', ref: '3a6acb3'

My parameters with //= require jquery.remotipart

Parameters: {"utf8"=>"✓", "authenticity_token"=>"kDFnZgJut5/2Xh+MNeuvHbiHXAMJp9VkMA52ifnurl851w0yRmw6nUFPsoDZ6pVqh/6FJnEoKABMt7rMagwuow==", "article_type"=>"news", "article"=>{"strings"=>{"1"=>{"title"=>"THIS IS THE TITLE", "text"=>"THIS IS THE TEXT"}}}}

My parameters right after removing //= require jquery.remotipart

Parameters: {"utf8"=>"✓", "authenticity_token"=>"4MZA/IRz4cIGqngV4cgmTNnSuFOw5r1zw3iCwRklRd9JICqowHFswLG71RkNyRw75qthdshpQBe/wU6EisfFIw==", "article_type"=>"news", "article"=> {"image"=>

<ActionDispatch::Http::UploadedFile:0x007f961bec2328

 @content_type="image/png",
 @headers="Content-Disposition: form-data; name=\"article[image]\"; filename=\"1194986855125869974rubik_s_cube_random_petr_01.svg.med.png\"\r\nContent-Type: image/png\r\n",
 @original_filename="1194986855125869974rubik_s_cube_random_petr_01.svg.med.png",
 @tempfile=#<File:/tmp/RackMultipart20160630-23416-1082nxz.png>>,

"strings"=>{"1"=>{"title"=>"asdasd", "text"=>"asdasdas"}}}}

My form regarding the issue:

<%=form_for @article, url: articles_create_path, remote: true, html: { multipart: true, class: "form-horizontal"} do |f|%>
        <%= hidden_field_tag 'article_type', @articleType  %>
        <fieldset class="content-group">
        <%if !(@articleType=='notifs') %>
          <legend class="text-bold">Image</legend>

          <div class="form-group">
            <div class="col-lg-10">
              <%= f.file_field :image, :class => 'file-input-custom', 'data-show-caption' => true, 'data-show-upload' => false, :accept => 'image/*'%> <div class="fileupload-loading"></div>
            </div>
          </div>
          <% end %>
        </fieldset>
        <%= f.fields_for :strings do |fa| %>
        <fieldset class="content-group">
          <legend class="text-bold">Localization</legend>
          <div class="tabbable">

            <div class="tab-content">
              <% @languages.each do |lang| %>
              <%= fa.fields_for lang.id.to_s do |fb| %>

              <div class="tab-pane active" id="basic-justified-tab-<%= lang.id %>">
                <div class="form-group">
                  <label class="col-lg-2 control-label text-semibold"><%= lang.name %> Title: <span class="text-danger">*</span></label>
                  <div class="col-lg-10">
                    <%= fb.text_field :title, :class => 'form-control', :required => 'required' %>
                  </div>
                </div>

                <div class="form-group">
                  <label for="title" class="col-md-4 col-md-offset-1"><%= lang.name %> Text:</label>
                  <%= fb.text_area :text, :style => "height: 150px;", :class => 'wysihtml5 wysihtml5-min form-control', :required => 'required' %>
                </div>
              </div>
              <hr>

              <% end %>
              <% end %>
            </div>
          </div>

        </fieldset>
        <% end %>                              

        <div class="form-group">

          <div class="col-md-2 col-md-offset-8">
            <input type="submit" class="btn btn-success" value="Submit" >
          </div>

        </div>

        <% end %>

I am starting to get desperate, 4 days now and I can't find the solution to this. Any help appreciated.