title: Active Record - Delete all dependent values only if its present in child table
body: <p>I am working in an Rails app, i am aware of <code>:dependent => delete_all</code> functionality in a Model.</p>
  
  <p>Consider the below example</p>
  
  <pre><code>class TableA &lt; ActiveRecord::Base 
  
      has_many :tablebs, :dependent =&gt; :delete_all
  
  end
  
  
  class TableB &lt; ActiveRecord::Base 
  
      belongs_to :tablea
  
  end
  </code></pre>
  
  <p>If there is corresponding foreign key reference in TableB which represents TableA,
  then deleting record in TableA using Active record will delete all the corresponding 
  rows in TableB.</p>
  
  <p>But when there is no corresponding values in TableB, it shows like </p>
  
  <p><code>uninitialized constant TableA::TableB</code></p>
  
  <p>What i am trying to achieve is, the Active Record should delete dependent values if its present and
  ignore the step if there is no dependent values.</p>
  
  <p>Is this possible? </p>
  
  <p>thanks,
  Balan</p>