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 }, { resource_id => 2 } ], }); $c->redirect($c->uri_for('/nation')); } else { $c->stash->{error_msg} = "Nation name already taken!"; } } return $c->stash->{template} = 'nation/create.tt2'; }