# Call create() on the book model object. Pass the table
# columns/field values we want to set as hash values
- my $book = $c->model('MyAppDB::Books')->create({
+ my $book = $c->model('DB::Books')->create({
title => $title,
rating => $rating
});
my $author_id = $c->request->params->{author_id} || '1';
# Create the book
- my $book = $c->model('MyAppDB::Books')->create({
+ my $book = $c->model('DB::Books')->create({
title => $title,
rating => $rating,
});
</td>
<td>
[% # Add a link to delete a book %]
- <a href="[% Catalyst.uri_for('delete/') _ book.id %]">Delete</a>
+ <a href="[% Catalyst.uri_for('delete', book.id) %]">Delete</a>
</td>
</tr>
[% END -%]
my ($self, $c, $id) = @_;
# Search for the book and then delete it
- $c->model('MyAppDB::Books')->search({id => $id})->delete_all;
+ $c->model('DB::Books')->search({id => $id})->delete_all;
# Set a status message to be displayed at the top of the view
$c->stash->{status_msg} = "Book deleted.";
my ($self, $c, $id) = @_;
# Search for the book and then delete it
- $c->model('MyAppDB::Books')->search({id => $id})->delete_all;
+ $c->model('DB::Books')->search({id => $id})->delete_all;
# Set a status message to be displayed at the top of the view
$c->stash->{status_msg} = "Book deleted.";
my ($self, $c, $id) = @_;
# Search for the book and then delete it
- $c->model('MyAppDB::Books')->search({id => $id})->delete_all;
+ $c->model('DB::Books')->search({id => $id})->delete_all;
# Redirect the user back to the list page with status msg as an arg
$c->response->redirect($c->uri_for('/books/list',
most recent version of the Catalyst Tutorial can be found at
L<http://dev.catalyst.perl.org/repos/Catalyst/trunk/Catalyst-Manual/lib/Catalyst/Manual/Tutorial/>.
-Copyright 2006, Kennedy Clark, under Creative Commons License
+Copyright 2006-2008, Kennedy Clark, under Creative Commons License
(L<http://creativecommons.org/licenses/by-nc-sa/2.5/>).