0

Hi Im working with a form and have added :remote => true to the form and the destroy link. But when I do that this happends:

  1. I submit the form and it makes 2 versions that are the same.
  2. I destroy, I get prompted twice?
  3. If i remove the :remote => true it only makes one version and only prompt once.

This is my form

<%= 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 %>

This is my destroy link

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

Am I doing something very wrong here? Thanks in advance!

Philip
  • 6,827
  • 13
  • 75
  • 104

1 Answers1

1

I think you have included your rails.js file twice. that might be the problem. check it.

Ashish
  • 5,723
  • 2
  • 24
  • 25