NoMethodError at /delete/1 private method `delete' called for #<Ad:0x102945180> (Sinatra screencast)

88 views
Skip to first unread message

joe

unread,
Nov 29, 2009, 6:38:10 PM11/29/09
to PeepCode
Hello,

I'm currently working through the Sinatra screencast and have received
an error I don't really understand.

I'm at the point of deleting the first ad (~00:37:00) but Sinatra
complains about the delete method in the delete handler.

Here's the delete handler code:

http://pastie.org/719654

And here's the error I'm receiving:

NoMethodError at /delete/1
private method `delete' called for #<Ad:0x102945180>

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

Line 72 is "ad.delete"

I dont think I typed anything wrong. Nothing I can see anyway. Am I
missing something? My entire adserver.rb file looks like this:

http://pastie.org/719652

Thank you,

Joe

David A McClain

unread,
Dec 2, 2009, 12:48:05 PM12/2/09
to peep...@googlegroups.com
I had that too. Don't know why but Sinatra was complaining that I was
calling a private method. I changed "ad.delete" to "ad.destroy" which
seemed to work just fine.

David

-
ma...@davidamcclain.com
http://davidamcclain.com
web design and development
> --
>
> You received this message because you are subscribed to the Google
> Groups "PeepCode" group.
> To post to this group, send email to peep...@googlegroups.com.
> To unsubscribe from this group, send email to peepcode+u...@googlegroups.com
> .
> For more options, visit this group at http://groups.google.com/group/peepcode?hl=en
> .
>
>

Ben Lovell

unread,
Dec 2, 2009, 1:10:58 PM12/2/09
to peep...@googlegroups.com
2009/11/29 joe <ehas...@gmail.com>
This is due to how Sinatra extends the app with it's own smarts. If you defined your "Ad" class in another file and required it in to your app file you wouldn't see this issue. Looks like a possible bug as this isn't really expected behaviour.

Cheers,
Ben
Reply all
Reply to author
Forward
0 new messages