Rails - PG Foreign Key Violation on DELETE
<p>I have an application that has <code>Venues</code> and <code>Clients</code>.</p>

<p>Each venue has many clients:</p>

<pre class="lang-ruby prettyprint-override"><code>class Venue &lt; ActiveRecord::Base
  has_many :clients
end
</code></pre>

<p>When I try to delete some venue, Postgres complains about foreign key constraint violation:</p>

<pre><code>PG::ForeignKeyViolation: ERROR: update or delete on table "venues" violates foreign key constraint "fk_rails_3afaf2f5fc" on table "clients" DETAIL: Key (id)=(3) is still referenced from table "clients". : DELETE FROM "venues" WHERE "venues"."id" = $1
</code></pre>

<p>It would be simple to solve by adding <code>dependent: :destroy</code> to the association.</p>

<p>But I want to keep the clients, even if they have no more venue.</p>