# NoMethodError at /delete/1 private method \`delete'

**URL:** <https://www.ruby-forum.com/t/nomethoderror-at-delete-1-private-method-delete/179596>\
**Category:** Ruby\
**Created:** [November 30, 2009, 2:50am UTC](https://www.ruby-forum.com/t/nomethoderror-at-delete-1-private-method-delete/179596 "2009-11-30T02:50:14Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jhosteny](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/bbe5ce/32.png) [@jhosteny](https://www.ruby-forum.com/u/jhosteny)\
**Post date:** [November 30, 2009, 2:50am UTC](https://www.ruby-forum.com/t/nomethoderror-at-delete-1-private-method-delete/179596/1 "2009-11-30T02:50:14Z")

</div>

Hello,

I’m trying to work through the ‘Meet Sinatra’ PeepCode screencast and  
I’m stuck trying to delete an entry.

I’m receiving this error while attempting to delete a file and database  
entry:

NoMethodError at /delete/1  
private method `delete’ called for #Ad:0x102949028

```
* file: adserver.rb
* location: GET /delete/:id
* line: 72

```

Here’s the entire adserver.rb file:  
[http://pastie.org/719776](http://pastie.org/719776)

Here’s the handler that’s causing problems:  
[http://pastie.org/719777](http://pastie.org/719777)

The error is being caused by: “ad.delete”

When the URL that is supposed to remove the file and delete the db entry  
is visited ([mysite.com/delete/1](http://mysite.com/delete/1)), the file is removed and then I receive  
the error that I posted above.

Any feedback is appreciated.

Thank you

---

<div class="post-metadata">

**Author:** ![jhosteny](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/bbe5ce/32.png) [@jhosteny](https://www.ruby-forum.com/u/jhosteny)\
**Post date:** [November 30, 2009, 5:03am UTC](https://www.ruby-forum.com/t/nomethoderror-at-delete-1-private-method-delete/179596/2 "2009-11-30T05:03:58Z")

</div>

On Nov 29, 2009, at 17:50 , Joe dude wrote:

> - file: adserver.rb
> - location: GET /delete/:id
> - line: 72
> 
> Here’s the entire adserver.rb file:  
> [http://pastie.org/719776](http://pastie.org/719776)
> 
> Here’s the handler that’s causing problems:  
> [http://pastie.org/719777](http://pastie.org/719777)

First off, you should probably ask this question either on the sinatra  
mailing list or the datamapper mailing list for a better and more  
accurate response.

Second, without a full backtrace we can only speculate.

If the method is private, make it public… but it is probably private  
for a reason. Looking at the API, you might want to call destroy  
instead.
