0

嗨,我正在使用一个表单,并在表单和销毁链接中添加了 :remote => true。但是当我这样做时,这发生了:

  1. 我提交了表格,它制作了 2 个相同的版本。
  2. 我破坏,我得到提示两次?
  3. 如果我删除 :remote => true 它只会制作一个版本并且只提示一次。

这是我的表格

<%= form_for([@comment], :remote => true) do |f| %>
    <% if @comment.errors.any? %>
        <div id="error_explanation">
          <h2><%= pluralize(@comment.errors.count, "error") %> prohibited this comment from being saved:</h2>

          <ul>
            <% @comment.errors.full_messages.each do |msg| %>
                <li><%= msg %></li>
            <% end %>
          </ul>
        </div>
    <% end %>

    <div class="field">
      <%= f.label :title %>
      <br/>
      <%= f.text_field :title %>
    </div>
    <div class="field">
      <%= f.label :body %>
      <br/>
      <%= f.text_area :body %>
    </div>
    <div class="field">
      <%= f.hidden_field :user_id %>
      <%= f.hidden_field :retailer_id %>

      <%= f.hidden_field :product_id %>
    </div>
    <div class="actions">
      <%= f.submit %>
    </div>
<% end %>

这是我的销毁链接

  <%= link_to 'Destroy', comment, :confirm => 'Are you sure?', :method => :delete, :remote => true %>

我在这里做错了什么吗?提前致谢!

4

1 回答 1

1

我认为您已经包含了您的 rails.js 文件两次。这可能是问题所在。核实。

于 2011-04-05T12:21:10.640 回答