uG has asked for the wisdom of the Perl Monks concerning the following question:
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.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'; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Help seperating business logic from controller (catalyst/dbic)
by stonecolddevin (Parson) on Sep 09, 2008 at 04:18 UTC | |
by uG (Scribe) on Sep 09, 2008 at 04:41 UTC | |
by perrin (Chancellor) on Sep 09, 2008 at 12:09 UTC | |
by uG (Scribe) on Sep 09, 2008 at 13:22 UTC | |
by perrin (Chancellor) on Sep 09, 2008 at 13:45 UTC | |
by stonecolddevin (Parson) on Sep 09, 2008 at 17:51 UTC | |
|
Re: Help seperating business logic from controller (catalyst/dbic)
by uG (Scribe) on Sep 10, 2008 at 04:46 UTC |