删除头像不适合我

时间:2017-04-12 18:17:49

标签: ruby-on-rails ruby carrierwave avatar

删除头像复选框在我的编辑表单中没有为我做任何事情。这是我的代码。

_form.html.erb

        var options = new ChromeOptions();
        // This was a PAIN. If this ever does not work, here is how I got the preference name:
        // 1. Navigate to : chrome://settings/content
        // 2. Scroll to the bottom "PDF Documents" section
        // 3. Right-Click and inspect element on the check box titled "Open PDF files in the default PDF viewer application"
        // 4. The preference name is the pref key for the input, in this case: pref="plugins.always_open_pdf_externally"
        options.AddUserProfilePreference("plugins.always_open_pdf_externally", true);

        // The constructor must be pointed to the chrome driver .exe
        // Or you must set a PATH variable pointing to the location
        using (var driver = new ChromeDriver(options))
        {
        ..........

儿童控制器

<%= simple_form_for(@child, html: { multipart: true}) do |f| %>

  <% if child.errors.any? %>
    <div id="error_explanation">
      <h2><%= pluralize(child.errors.count, "error") %> prohibited this child from being saved:</h2>

      <ul>
      <% child.errors.full_messages.each do |message| %>
        <li><%= message %></li>
      <% end %>
      </ul>
    </div>
  <% end %>


    <%= f.label :name %><br />
     <div class="field"><%= f.text_field(:name) %> <br /></div>

    <%= f.label :balance %><br />
     <div class="field"> <%= f.text_field(:balance) %> <br /></div>

    <%= f.label :parent_id %><b> ID</b><br />

     <%= f.number_field :parent_id, :value => current_parent.id, :readonly => true %><br />

     <%=f.label :avatar %><br />
     <%= image_tag(@child.avatar_url) if @child.avatar? %>
     <%= f.file_field(:avatar) %>
     <%= f.hidden_field(:avatar_cache) %>
     <br />
     <label>
     <%= f.check_box :remove_avatar %>
     Remove Avatar
     </label>

  <div class="actions">
    <% if @child.new_record? == true %>
    <%= f.submit("Add Child") %>
    <% else %>

    <%= f.submit("Save Child") %>
    <% end %>
  </div>


<% end %>

如果我点击保存并选中删除头像框,它对头像没有任何作用,如果我回到任何显示头像的页面,它仍然存在。我究竟做错了什么?我正在使用Ruby on Rails 5.0.1

旁注:我知道这里使用的一些已弃用的东西,例如before_filter。我正在和一大群人一起工作,所以不是所有这些代码都是我的,修复它现在不是优先考虑的事。

0 个答案:

没有答案