Mojolicious-Command-generate-resources

 view release on metacpan or  search on metacpan

lib/Mojolicious/resources/templates/mojo/command/resources/c_class.ep  view on Meta::CPAN

}

# GET /<%= $a->{t} %>/:id/edit 
# Display form for edititing resource in table <%= $a->{t} %>.
sub edit($c) {
  return $c->render(<%= $a->{t} %> => $c-><%= $a->{t} %>->find($c->param('id')));
}

# PUT /<%= $a->{t} %>/:id
# Update the record in table <%= $a->{t} %>
sub update($c) {

  # Validate input
  my $validation = $c->_validation;
  return $c->render(action => 'edit', <%= $a->{t} %> => {})
    if $validation->has_error;

  # Update the record
  my $id = $c->param('id');
  $c-><%= $a->{t} %>->save($id, $validation->output);

t/blog/lib/Blog/Controller/Posts.pm  view on Meta::CPAN

  my $self = shift;

  my $validation = $self->_validation;
  return $self->render(action => 'create', post => {})
    if $validation->has_error;

  my $id = $self->posts->add($validation->output);
  $self->redirect_to('show_post', id => $id);
}

sub update {
  my $self = shift;

  my $validation = $self->_validation;
  return $self->render(action => 'edit', post => {}) if $validation->has_error;

  my $id = $self->param('id');
  $self->posts->save($id, $validation->output);
  $self->redirect_to('show_post', id => $id);
}

 view all matches for this distribution
 view release on metacpan -  search on metacpan

( run in 0.519 second using v1.00-cache-2.02-grep-82fe00e-cpan-4673cadbf75 )