<ActiveRecord::Relation 删除全部(一条记录/实例) production 和development 日志的区分

删除全部 () 关联 、
ActiveRecord::Relation
删除记录而不首先实例化记录,因此不调用 #destroy 方法或调用回调。 这是一条直接进入数据库的 SQL DELETE 语句,比 destroy_all. 但要小心关系,特别是
:dependent
<code class="language-css">
<figure class="highlight"><pre><code class="language-html" data-lang="html">Post.where(person_id: 5).where(category: ['Something', 'Else']).delete_all</code></pre></figure>两个调用都使用一条 DELETE 语句一次性删除所有受影响的帖子。 如果您需要销毁依赖关联或致电您的
before_*after_destroy
如果提供了无效的方法, delete_all引发 ActiveRecordError:
<code class="language-ruby">
<figure class="highlight"><pre><code class="language-html" data-lang="html">Post.distinct.delete_all
# =<span class="ni">&gt;</span> ActiveRecord::ActiveRecordError: delete_all doesn't support distinct</code></pre></figure>delete_all() Link
Deletes the records without instantiating the records first, and hence not calling the #destroy method nor invoking callbacks. This is a single SQL DELETE statement that goes straight to the database, much more efficient than destroy_all. Be careful with relations though, in particular
:dependent
Post.where(person_id: 5).where(category: ['Something', 'Else']).delete_allBoth calls delete the affected posts all at once with a single DELETE statement. If you need to destroy dependent associations or call your
before_*after_destroy
If an invalid method is supplied, delete_all raises an ActiveRecordError:
Post.distinct.delete_all
# => ActiveRecord::ActiveRecordError: delete_all doesn't support distinct 
是通用的ruby环境
