diff --git a/lib/PostText/Controller/Remark.pm b/lib/PostText/Controller/Remark.pm index 8ec9a1d..c813802 100644 --- a/lib/PostText/Controller/Remark.pm +++ b/lib/PostText/Controller/Remark.pm @@ -57,6 +57,9 @@ sub create($self) { last_remark => $last_remark ); + $self->stash(status => 404, error => 'Thread not found 🤷') + unless keys %{$thread}; + return $self->render; } diff --git a/templates/remark/create.html.ep b/templates/remark/create.html.ep index 76f4a89..d66b78d 100644 --- a/templates/remark/create.html.ep +++ b/templates/remark/create.html.ep @@ -1,6 +1,7 @@ % layout 'default'; % title 'New Remark';

<%= title %>

+<% if (keys %{$thread}) { =%>
<% if (my $error = validation->error('author')) { =%> @@ -49,7 +50,8 @@
-<% if (my $last_remark_id = $last_remark->{'id'}) { =%> +<% } =%> +<% if (keys %{$last_remark}) { =%>

Last Remark

@@ -57,8 +59,8 @@ <%= $last_remark->{'date'} %> - <%= link_to "#$last_remark_id", single_remark => - {remark_id => $last_remark_id}, (class => 'post__id') %> + <%= link_to "#$last_remark->{'id'}", single_remark => + {remark_id => $last_remark->{'id'}}, (class => 'post__id') %>