Catalyst-Manual
view release on metacpan or search on metacpan
lib/Catalyst/Manual/Tutorial/04_BasicCRUD.pod view on Meta::CPAN
[debug] Loaded Path actions:
.-------------------------------------+--------------------------------------.
| Path | Private |
+-------------------------------------+--------------------------------------+
| / | /default |
| / | /index |
| /books | /books/index |
| /books/list | /books/list |
'-------------------------------------+--------------------------------------'
[debug] Loaded Chained actions:
.-------------------------------------+--------------------------------------.
| Path Spec | Private |
+-------------------------------------+--------------------------------------+
| /books/url_create/*/*/* | /books/url_create |
'-------------------------------------+--------------------------------------'
C<url_create> has disappeared from the "Loaded Path actions" section but
it now shows up under the newly created "Loaded Chained actions"
section. And the "/*/*/*" portion clearly shows our requirement for
three arguments.
As with our non-chained version of C<url_create>, use your browser to
enter the following URL:
http://localhost:3000/books/url_create/TCPIP_Illustrated_Vol-2/5/4
You should see the same "Added book 'TCPIP_Illustrated_Vol-2' by
'Stevens' with a rating of 5." along with a dump of the new book model
lib/Catalyst/Manual/Tutorial/04_BasicCRUD.pod view on Meta::CPAN
working with now), we will instead add that functionality to a common
C<object> action shortly.
As for C<url_create>, let's modify it to first dispatch to C<base>.
Open up F<lib/MyApp/Controller/Books.pm> and edit the declaration for
C<url_create> to match the following:
sub url_create :Chained('base') :PathPart('url_create') :Args(3) {
Once you save F<lib/MyApp/Controller/Books.pm>, notice that the
development server will restart and our "Loaded Chained actions" section
will changed slightly:
[debug] Loaded Chained actions:
.-------------------------------------+--------------------------------------.
| Path Spec | Private |
+-------------------------------------+--------------------------------------+
| /books/url_create/*/*/* | /books/base (0) |
| | => /books/url_create |
'-------------------------------------+--------------------------------------'
The "Path Spec" is the same, but now it maps to two Private actions as
we would expect. The C<base> method is being triggered by the C</books>
part of the URL. However, the processing then continues to the
lib/Catalyst/Manual/Tutorial/04_BasicCRUD.pod view on Meta::CPAN
$c->stash(book => $book,
template => 'books/create_done.tt2');
}
=head2 Test Out The Form
Notice that the server startup log reflects the two new chained methods
that we added:
[debug] Loaded Chained actions:
.-------------------------------------+--------------------------------------.
| Path Spec | Private |
+-------------------------------------+--------------------------------------+
| /books/form_create | /books/base (0) |
| | => /books/form_create |
| /books/form_create_do | /books/base (0) |
| | => /books/form_create_do |
| /books/url_create/*/*/* | /books/base (0) |
| | => /books/url_create |
'-------------------------------------+--------------------------------------'
lib/Catalyst/Manual/Tutorial/04_BasicCRUD.pod view on Meta::CPAN
completed, C<detach> does I<not> return. Other than that, the two are
equivalent.
=head2 Try the Delete Feature
Once you save the Books controller, the server should automatically
restart. The C<delete> method should now appear in the "Loaded Chained
actions" section of the startup debug output:
[debug] Loaded Chained actions:
.-------------------------------------+--------------------------------------.
| Path Spec | Private |
+-------------------------------------+--------------------------------------+
| /books/id/*/delete | /books/base (0) |
| | -> /books/object (1) |
| | => /books/delete |
| /books/form_create | /books/base (0) |
| | => /books/form_create |
| /books/form_create_do | /books/base (0) |
| | => /books/form_create_do |
( run in 0.938 second using v1.01-cache-2.11-cpan-71847e10f99 )