Hi there I'm developing a Catalyst website and have kind of been learning as I'm going along, but now know enough (almost) to go and rewrite chunks of it. Up until now I've been doing my create / update error checking in my controller (which I know is not recommended) - I'm now moving it to the model, but have hit a snag. Consider a table ('clubs'), one of whose columns ('venue') has a 'belongs_to' relationship with another table ('venues'). Previously, to do my error checking, I've been able to do something like this:
my $venue_check = $c->model("DB::Venue")->find($venue); $error .= "The venue is not valid.\n" if !defined($venue_check);
Now from my model Resultset class, I can check anything in the current table with $self->find(), etc., but am unsure how to query a different table without passing in $c as one of the arguments from the controller (which is obviously regarded as a cardinal sin and kind of defeats the object of doing it in the model). Many thanks in advance for any assistance. Chris

In reply to Catalyst / DBIx::Class - accessing a different table from the model by mkchris

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.