开发者

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜