小编Syl*_*aux的帖子

如何知道模型何时被自动去除:依赖=>:在rails中销毁?

我有以下关联:

class Parent < ActiveRecord::Base
  has_many :children, :dependent => :destroy
  before_destroy :do_some_stuff
end

class Child < ActiveRecord::Base
  belongs_to :parent
  before_destroy :do_other_stuff
end
Run Code Online (Sandbox Code Playgroud)

我想在do_other_stuff中知道,如果销毁是由dependent => destroy发生的,因为它的一部分会/将在do_some_stuff中完成

我试过parent.destroyed?,parent.marked_for_destruction?,parent.frozen?但没有工作:/

有任何想法吗?

activerecord ruby-on-rails associations destroy

5
推荐指数
1
解决办法
870
查看次数

在 ansible playbook 中动态设置 HTTP_PROXY

我正在一堆不需要 http_proxy 的服务器和其他需要它的服务器上运行剧本(在不同的运行中)。

我已经阅读了https://docs.ansible.com/ansible/latest/user_guide/playbooks_environment.html但它并没有真正回答这个问题......

这是一个例子:

- hosts: all tasks: - name: install vi become: true apt: name: vi state: present

我想在没有代理的情况下使用一组服务器(假设 server01-atlanta)启动它,并在另一个运行中使用一组服务器(假设 server01-berlin)使用代理启动它,并且不更改每次运行之间的代码(因此设​​法用库存变量来做)。

我会

proxy http-proxy ansible

3
推荐指数
1
解决办法
7111
查看次数