[Catalyst] Problem with static model in
Tutorial::MoreCatalystBasics
J. Shirley
jshirley at gmail.com
Wed Mar 11 13:59:47 GMT 2009
On Wed, Mar 11, 2009 at 6:26 AM, Adam Witney <awitney at sgul.ac.uk> wrote:
>
> On 11 Mar 2009, at 13:10, Tomas Doran wrote:
>
> Adam Witney wrote:
>>
>>> 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
>>>
>>>
>>> http://dev.catalyst.perl.org/repos/Catalyst/Catalyst-Manual/5.70/trunk/=
lib/Catalyst/Manual/Tutorial/MoreCatalystBasics.pod
>>>
>> 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).
>>
>
> is this what you mean?
>
> ---
> Catalyst-Manual-5.7018/lib/Catalyst/Manual/Tutorial/MoreCatalystBasics.pod
> 2009-03-08 23:56:26.000000000 +0000
> +++ MoreCatalystBasics.pod 2009-03-11 13:23:00.000000000 +0000
> @@ -1105,7 +1105,7 @@
> C<lib/MyApp/Model/DB.pm>. This file contains a reference to
> C<lib/MyApp/Schema.pm>, so that file is loaded next. Finally, the
> call to C<load_classes> in C<Schema.pm> will load each of the "result
> -class" files from the C<lib/MyApp/Schema> subdirectory. The end
> +class" files from the C<lib/MyApp/Schema/Result> subdirectory. The end
> result is that Catalyst will dynamically create three table-specific
> Catalyst models every time the application starts (you can see these
> three model files listed in the debug output generated when you launch
> @@ -1126,7 +1126,7 @@
> Result Class files. (Note: if you are using a database other than
> SQLite, such as PostgreSQL, then the relationship could have been
> automatically placed in the Result Class files. If so, you can skip
> -this step.) First edit C<lib/MyApp/Schema/Books.pm> and add the
> +this step.) First edit C<lib/MyApp/Schema/Result/Books.pm> and add the
> following text below the C<# You can replace this text...> comment:
>
> #
> @@ -1138,7 +1138,7 @@
> # 1) Name of relationship, DBIC will create accessor with this na=
me
> # 2) Name of the model class referenced by this relationship
> # 3) Column name in *foreign* table (aka, foreign key in peer
> table)
> - __PACKAGE__->has_many(book_authors =3D> 'MyApp::Schema::BookAuthors',
> 'book_id');
> + __PACKAGE__->has_many(book_authors =3D>
> 'MyApp::Schema::Result::BookAuthors', 'book_id');
>
> # many_to_many():
> # args:
> @@ -1178,7 +1178,7 @@
> Note that you cannot define a C<many_to_many> relationship without
> also having the C<has_many> relationship in place.
>
> -Then edit C<lib/MyApp/Schema/Authors.pm> and add relationship
> +Then edit C<lib/MyApp/Schema/Result/Authors.pm> and add relationship
> information as follows (again, be careful to put in above the C<1;> but
> below the C<# DO NOT MODIFY THIS OR ANYTHING ABOVE!> comment):
>
> @@ -1191,7 +1191,7 @@
> # 1) Name of relationship, DBIC will create accessor with this na=
me
> # 2) Name of the model class referenced by this relationship
> # 3) Column name in *foreign* table (aka, foreign key in peer
> table)
> - __PACKAGE__->has_many(book_author =3D> 'MyApp::Schema::BookAuthors',
> 'author_id');
> + __PACKAGE__->has_many(book_author =3D>
> 'MyApp::Schema::Result::BookAuthors', 'author_id');
>
> # many_to_many():
> # args:
> @@ -1202,7 +1202,7 @@
> __PACKAGE__->many_to_many(books =3D> 'book_author', 'book');
>
> Finally, do the same for the "join table,"
> -C<lib/MyApp/Schema/BookAuthors.pm>:
> +C<lib/MyApp/Schema/Result/BookAuthors.pm>:
>
> #
> # Set relationships:
> @@ -1213,14 +1213,14 @@
> # 1) Name of relationship, DBIC will create accessor with this na=
me
> # 2) Name of the model class referenced by this relationship
> # 3) Column name in *this* table
> - __PACKAGE__->belongs_to(book =3D> 'MyApp::Schema::Books', 'book_id');
> + __PACKAGE__->belongs_to(book =3D> 'MyApp::Schema::Result::Books',
> 'book_id');
>
> # belongs_to():
> # args:
> # 1) Name of relationship, DBIC will create accessor with this na=
me
> # 2) Name of the model class referenced by this relationship
> # 3) Column name in *this* table
> - __PACKAGE__->belongs_to(author =3D> 'MyApp::Schema::Authors',
> 'author_id');
> + __PACKAGE__->belongs_to(author =3D> 'MyApp::Schema::Result::Authors',
> 'author_id');
>
>
> =3Dhead2 Run The Application
> @@ -1249,7 +1249,7 @@
>
> Let's add a new column to our book list page that takes advantage of
> the relationship information we manually added to our schema files in
> -the previous section. Edit C<root/src/books/list.tt2> add add the
> +the previous section. Edit C<root/src/books/list.tt2> and add the
> following code below the existing table cell that contains
> C<book.rating> (IOW, add a new table cell below the existing two
> C<E<lt>tdE<gt>> tags but above the closing C<E<lt>/trE<gt>> and
>
>
>
The line in the tutorial to create the static files is this:
$ script/myapp_create.pl model DB DBIC::Schema MyApp::Schema
create=3Dstatic dbi:SQLite:myapp.db
I don't see where you got 'Result' as part of the class name.
-J
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/catalyst/attachments/20090311/dc196=
b28/attachment.htm
More information about the Catalyst
mailing list