<div class="gmail_quote">On Wed, Mar 11, 2009 at 6:26 AM, Adam Witney <span dir="ltr"><<a href="mailto:awitney@sgul.ac.uk">awitney@sgul.ac.uk</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="im"><br>
On 11 Mar 2009, at 13:10, Tomas Doran wrote:<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Adam Witney wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
ok, so i posted too soon and have figured out the problem. I need to add "Result" into the relationships. Does the Tutorial need to be updated to reflect this? If so i have included below a quick patch against<br>
<br>
<a href="http://dev.catalyst.perl.org/repos/Catalyst/Catalyst-Manual/5.70/trunk/lib/Catalyst/Manual/Tutorial/MoreCatalystBasics.pod" target="_blank">http://dev.catalyst.perl.org/repos/Catalyst/Catalyst-Manual/5.70/trunk/lib/Catalyst/Manual/Tutorial/MoreCatalystBasics.pod</a><br>
</blockquote>
Can you re-submit as a unified diff against the base of the Catalyst-Manual distribution? (this makes it much easier for someone to read / apply).<br>
</blockquote>
<br></div>
is this what you mean?<br>
<br>
--- Catalyst-Manual-5.7018/lib/Catalyst/Manual/Tutorial/MoreCatalystBasics.pod 2009-03-08 23:56:26.000000000 +0000<br>
+++ MoreCatalystBasics.pod 2009-03-11 13:23:00.000000000 +0000<br>
@@ -1105,7 +1105,7 @@<br>
C<lib/MyApp/Model/DB.pm>. This file contains a reference to<br>
C<lib/MyApp/Schema.pm>, so that file is loaded next. Finally, the<br>
call to C<load_classes> in C<Schema.pm> will load each of the "result<br>
-class" files from the C<lib/MyApp/Schema> subdirectory. The end<div class="im"><br>
+class" files from the C<lib/MyApp/Schema/Result> subdirectory. The end<br></div>
result is that Catalyst will dynamically create three table-specific<br>
Catalyst models every time the application starts (you can see these<br>
three model files listed in the debug output generated when you launch<br>
@@ -1126,7 +1126,7 @@<br>
Result Class files. (Note: if you are using a database other than<br>
SQLite, such as PostgreSQL, then the relationship could have been<br>
automatically placed in the Result Class files. If so, you can skip<br>
-this step.) First edit C<lib/MyApp/Schema/Books.pm> and add the<div class="im"><br>
+this step.) First edit C<lib/MyApp/Schema/Result/Books.pm> and add the<br></div>
following text below the C<# You can replace this text...> comment:<br>
<br>
#<br>
@@ -1138,7 +1138,7 @@<br>
# 1) Name of relationship, DBIC will create accessor with this name<br>
# 2) Name of the model class referenced by this relationship<br>
# 3) Column name in *foreign* table (aka, foreign key in peer table)<br>
- __PACKAGE__->has_many(book_authors => 'MyApp::Schema::BookAuthors', 'book_id');<div class="im"><br>
+ __PACKAGE__->has_many(book_authors => 'MyApp::Schema::Result::BookAuthors', 'book_id');<br>
<br></div>
# many_to_many():<br>
# args:<br>
@@ -1178,7 +1178,7 @@<br>
Note that you cannot define a C<many_to_many> relationship without<br>
also having the C<has_many> relationship in place.<br>
<br>
-Then edit C<lib/MyApp/Schema/Authors.pm> and add relationship<div class="im"><br>
+Then edit C<lib/MyApp/Schema/Result/Authors.pm> and add relationship<br></div>
information as follows (again, be careful to put in above the C<1;> but<br>
below the C<# DO NOT MODIFY THIS OR ANYTHING ABOVE!> comment):<br>
<br>
@@ -1191,7 +1191,7 @@<br>
# 1) Name of relationship, DBIC will create accessor with this name<br>
# 2) Name of the model class referenced by this relationship<br>
# 3) Column name in *foreign* table (aka, foreign key in peer table)<br>
- __PACKAGE__->has_many(book_author => 'MyApp::Schema::BookAuthors', 'author_id');<div class="im"><br>
+ __PACKAGE__->has_many(book_author => 'MyApp::Schema::Result::BookAuthors', 'author_id');<br>
<br></div>
# many_to_many():<br>
# args:<br>
@@ -1202,7 +1202,7 @@<br>
__PACKAGE__->many_to_many(books => 'book_author', 'book');<br>
<br>
Finally, do the same for the "join table,"<br>
-C<lib/MyApp/Schema/BookAuthors.pm>:<div class="im"><br>
+C<lib/MyApp/Schema/Result/BookAuthors.pm>:<br>
<br></div>
#<br>
# Set relationships:<br>
@@ -1213,14 +1213,14 @@<br>
# 1) Name of relationship, DBIC will create accessor with this name<br>
# 2) Name of the model class referenced by this relationship<br>
# 3) Column name in *this* table<br>
- __PACKAGE__->belongs_to(book => 'MyApp::Schema::Books', 'book_id');<div class="im"><br>
+ __PACKAGE__->belongs_to(book => 'MyApp::Schema::Result::Books', 'book_id');<br>
<br></div>
# belongs_to():<br>
# args:<br>
# 1) Name of relationship, DBIC will create accessor with this name<br>
# 2) Name of the model class referenced by this relationship<br>
# 3) Column name in *this* table<br>
- __PACKAGE__->belongs_to(author => 'MyApp::Schema::Authors', 'author_id');<div class="im"><br>
+ __PACKAGE__->belongs_to(author => 'MyApp::Schema::Result::Authors', 'author_id');<br>
<br>
<br></div>
=head2 Run The Application<br>
@@ -1249,7 +1249,7 @@<br>
<br>
Let's add a new column to our book list page that takes advantage of<br>
the relationship information we manually added to our schema files in<br>
-the previous section. Edit C<root/src/books/list.tt2> add add the<br>
+the previous section. Edit C<root/src/books/list.tt2> and add the<br>
following code below the existing table cell that contains<br>
C<book.rating> (IOW, add a new table cell below the existing two<br>
C<E<lt>tdE<gt>> tags but above the closing C<E<lt>/trE<gt>> and<div><div></div><div class="h5"><br>
<br></div></div></blockquote><div><br></div><div>The line in the tutorial to create the static files is this:</div><p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 13.0px Courier"> $ script/myapp_create.pl model DB DBIC::Schema MyApp::Schema create=static dbi:SQLite:myapp.db</p>
<div> </div><div>I don't see where you got 'Result' as part of the class name.</div></div><div><br></div>-J<br>