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
3233343536373839404142434445464748495051}
# 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
2829303132333435363738394041424344454647
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
);
}
( run in 3.432 seconds using v1.01-cache-2.11-cpan-26ccb49234f )