X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Manual.git;a=blobdiff_plain;f=lib%2FCatalyst%2FManual%2FTutorial%2FBasicCRUD.pod;h=0aa7e2ce96f591088d783bb75291838e369d16b3;hp=f2565f2bc4c15a4116bcb353ce9e115fef21b404;hb=994b66ad3ec2a66fb5d22957474229422b9ce110;hpb=8a0214b4275e310f64f74c2a250a20c01efd4c66
diff --git a/lib/Catalyst/Manual/Tutorial/BasicCRUD.pod b/lib/Catalyst/Manual/Tutorial/BasicCRUD.pod
index f2565f2..0aa7e2c 100644
--- a/lib/Catalyst/Manual/Tutorial/BasicCRUD.pod
+++ b/lib/Catalyst/Manual/Tutorial/BasicCRUD.pod
@@ -390,7 +390,7 @@ object. Click the "Return to list" link, you should find that there
are now seven books shown (two copies of TCPIP_Illustrated_Vol-2).
-=head2 Refactor to Use a "Base" Method to Start The Chains
+=head2 Refactor to Use a "Base" Method to Start the Chains
Let's make a quick update to our initial Chained action to show a
little more of the power of chaining. First, open
@@ -405,20 +405,28 @@ method:
sub base :Chained('/') :PathPart('books') :CaptureArgs(0) {
my ($self, $c) = @_;
+
+ # Store the resultset in stash so it's available for other methods
+ $c->stash->{resultset} = $c->model('DB::Books');
+ # Print a message to the debug log
$c->log->debug('*** INSIDE BASE METHOD ***');
}
-Although we only use the C method to create a log message, we
-could obviously do any number of things here. For example, if your
-controller always needs a book ID as it's first argument, you could
-have the base method capture that argument (with C<:CaptureArgs(1)>)
-and use it to pull the book object with that ID from the database and
-leave it in the stash for later parts of your chains to then act upon.
-
-In our case, let's modify our C method to first call
-C. Open up C and edit the
-declaration for C to match the following:
+Here we print a log message and store the resultset in
+C<$c-Estash-E{resultset}> so that it's automatically available
+for other actions that chain off C. If your controller always
+needs a book ID as it's first argument, you could have the base method
+capture that argument (with C<:CaptureArgs(1)>) and use it to pull the
+book object with that ID from the database and leave it in the stash for
+later parts of your chains to then act upon. Because we have several
+actions that don't need to retrieve a book (such as the C
+we are working with now), we will instead add that functionality
+to a common C