开发者

Rails: Change _destroy functionality?

开发者 https://www.devze.com 2023-02-23 12:01 出处:网络
I\'m using accepts_nested_attributes_for for some nested resources and am using the _destroy flag to remove an item on form save.

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 r开发者_运维百科ecord, I'd like it to just update an active boolean field to be false.

How can I do that?


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

精彩评论

暂无评论...
验证码 换一张
取 消