I'm probably not doing this the right way, I should be generating the new model automatically through some kind of script?

But it's not a 100% standard Catalyst setup, and I'm kind of in a hurry.

I have a set of Models already in the site which look like this:

use utf8; package Model::DB::Result::Thing; use base 'DBIx::Class::Core'; use strict; use warnings; __PACKAGE__->table("things"); # etc. etc. some fields are defined here __PACKAGE__->add_columns( "id", { data_type => "integer", is_auto_increment => 1, is_nullable => 0, }, "name", { data_type => "text", is_nullable => 1 },

So I need to add another Model along the lines of:

use utf8; package Model::DB::Result::OtherThing; use base 'DBIx::Class::Core'; use strict; use warnings; __PACKAGE__->table("otherthings"); # etc. etc. some fields are defined here __PACKAGE__->add_columns( "id", { data_type => "integer", is_auto_increment => 1, is_nullable => 0, }, "othername", { data_type => "text", is_nullable => 1 },

And I'm doing it by the naïve method of putting a new OtherThing.pm into the same directory, restarting, and trying to call on it from a Controller.

This doesn't work and I get [error] Caught exception in Console::Controller::OtherThing->create "Can't call method "create" on an undefined value at /var/www/Payment/Console/lib/Console/Controller/OtherThing.pm line xx."

Where the undefined thing is $c->model('OtherThing')

So is there some other flag or listing or module which controls which of my Models get loaded? There's a load_namespaces step in booting up Catalyst, I know that much.

Happy to do it the correct way via the correct script if I can, but I need to get it working either way.

I can see the Model being loaded when Catalyst starts up, by the way:

[debug] Loaded components: .--------------------------------------------------------------------- +------------------------------------+----------. | Class + | Type | +--------------------------------------------------------------------- +------------------------------------+----------+ | Console::Controller::OtherThing + | instance | | [snip] + | | | Console::Model::DB::Thing + | class | | Console::Model::DB::OtherThing + | class |

In reply to I need help adding a new model to a legacy Catalyst setup by LittleJack

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.