title: Destroying dependents in Datamapper
body: <p>Using Datamapper, I have a model Album that has n, :photos which has a Paperclip::Resource</p>
  
  <p>With ActiveRecord I would just have had:</p>
  
  <pre><code>has_many :photos, dependent: :destroy
  </code></pre>
  
  <p>in my Album model, in order to delete the photos at the same time as the Album, but with Datamapper it seems you have to roll your own. In Sinatra, to delete the album I have:</p>
  
  <pre><code>delete '/albums/:id' do
    a = Album.get params[:id] 
    a.destroy
    redirect '/'
  end
  </code></pre>
  
  <p>and a before filter in the Album model:</p>
  
  <pre><code>before :destroy do
    photos.destroy
  end
  </code></pre>
  
  <p>but the before filter is never called.</p>
  
  <p>If I put use the bang method, a.destroy!, the album is destroyed but not the Photos.</p>
  
  <p>No errors are produced and no Exceptions raised.</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>There are errors, but with an empty errors hash:</p>
  
  <pre><code>INFO -- : #&lt;DataMapper::Validations::ValidationErrors:0x13740dc @resource=#&lt;Album @id=2 @name="Quaver" @created_at=#&lt;DateTime: 2013-02-07T10:30:36+00:00 (5895194251/2400,0/1,2299161)&gt; @updated_at=#&lt;DateTime: 2013-02-07T10:30:36+00:00 (5895194251/2400,0/1,2299161)&gt;&gt;, @errors={}&gt;
  </code></pre>
  
  <p>So clearly I have validation issues. However I have not set any validations in my Models:</p>
  
  <pre><code>class Photo  
    include DataMapper::Resource
    include Paperclip::Resource  
  
    property :id, Serial
    property :title, String
    property :created_at, DateTime  
    property :updated_at, DateTime
  
    has_attached_file :data, url: "/:attachment/:id/:style/:basename.:extension",
                         path: "#    {APP_ROOT}/public/:attachment/:id/:style/:basename.:extension"
    belongs_to :album
  end
  
  class Album  
    include DataMapper::Resource  
    property :id, Serial
    property :name, String
    property :created_at, DateTime  
    property :updated_at, DateTime
    has n, :photos
  
    before :destroy do
      photos.destroy
    end
  end
  </code></pre>
  
  <p>So the before filter is not being called because of the ValidationErrors, but where do they come from when they are not explicitly set?</p>
  
  <p>Any help, gratefully received. Thanks.</p>