I was reading a new interview with mst today about the moose port of catalyst, and caught a few things he mentioned that I (as a new catalyst/mvc user) don't think i'm doing. The piece of code i'm including basically checks to see if a form has been filled out, and if so does some stuff. Otherwise, it shows the form that needs to be filled out.
sub create :Local{ my ( $self, $c ) = @_; my $nation = $c->request->params->{nation}; #Action Logic; Form was submitted, lets create then #Check to see if the nation name already exists if($nation) { unless($c->model('DB::Nation')->find({name => $nation})) { #If not, create the new nation! $c->user->nations->create({ name => $nation, owner => $c->user->get('id'), map_nation_resource => [ { resource_id => 1 }, { re +source_id => 2 } ], }); $c->redirect($c->uri_for('/nation')); } else { $c->stash->{error_msg} = "Nation name already taken!"; } } return $c->stash->{template} = 'nation/create.tt2'; }
Really i'm just still wet behind the ears and want to be sure i'm understanding these mvc techniques :) EDIT: I'm basically just asking if how I handled that action is good practice or not.

In reply to Help seperating business logic from controller (catalyst/dbic) by uG

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.