I just finished the tutorial on CPAN a couple of weeks ago. A join is created shortly after your first code sample.

# Add a record to the join table for this book, mapping to # appropriate author $book->add_to_book_authors({author_id => $author_id}); # Note: Above is a shortcut for this: # $book->create_related('book_authors', {author_id => $author_ +id}); # Assign the Book object to the stash for display in the view $c->stash->{book} = $book;

As for your second question. You need to show me what you have in the list subroutine for me to understand what is going on. Your template file is calling 'books/list' which means 'sub list' in Books.pm (you should have created that in the previous tutorial "More Catalyst Basics' In the tutorial on CPAN it looks like this:

sub list : Local { # Retrieve the usual Perl OO '$self' for this object. $c is th +e Catalyst # 'Context' that's used to 'glue together' the various compone +nts # that make up the application my ($self, $c) = @_; # Retrieve all of the book records as book model objects and s +tore in the # stash where they can be accessed by the TT template $c->stash->{books} = [$c->model('DB::Books')->all]; # Set the TT template to use. You will almost always want to +do this # in your action methods (action methods respond to user input + in # your controllers). $c->stash->{template} = 'books/list.tt2'; }

If you haven't been there yet you can find all the most updated chapters on CPAN here

-Actualize

In reply to Re: Catalyst: model & context object usage by actualize
in thread Catalyst: model & context object usage by marscld

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.