Permalink
Browse files

updating our controller: deleting posts

  • Loading branch information...
1 parent 76eed74 commit bfa937d034bd8758936fab51657d33d68fdc31e4 @garu committed Jun 13, 2010
Showing with 15 additions and 0 deletions.
  1. +15 −0 tweetylicious.pl
View
@@ -187,6 +187,21 @@ package main;
};
+get '/:user/post/:id/delete' => sub {
+ my $self = shift;
+
+ # user can only delete posts for their own account
+ $self->redirect_to('/')
+ unless $self->session('name') eq $self->param('user');
+
+ my $post = Model::Post->select('WHERE id = ?', $self->param('id'));
+ $post->[0]->delete if $post->[0];
+
+ # render the user page again
+ $self->redirect_to('/' . $self->session('name'));
+};
+
+
# let's rock and roll!
shagadelic;

0 comments on commit bfa937d

Please sign in to comment.