Shpigford
Shpigford

Reputation: 25378

Rails: Change _destroy functionality?

I'm using accepts_nested_attributes_for for some nested resources and am using the _destroy flag to remove an item on form save.

But instead of _destroy actually running DELETE on a record, I'd like it to just update an active boolean field to be false.

How can I do that?

Upvotes: 0

Views: 318

Answers (1)

fl00r
fl00r

Reputation: 83680

Ehm.. So why do you use _destroy? Just add active checkbox istead of _destroy

<%= form_for @object do |f| %>
  ...
  <%= f.fields_for @some_nested_object do |b| %>
    ...
    <%= b.check_box :active %>
    ...
  <% end %>
  ...
<% end %>

Upvotes: 3

Related Questions