phildeman has asked for the wisdom of the Perl Monks concerning the following question:
Hi All,
I am having a bit of a problem with DateTime objects and $c->flash.
I am using Perl Catalyst, Mason, DBIx::Class, where the DBIx::Class database packages uses DBIx::Class::InflateColumn::DateTime.
Where any column with a date or datetime data type can be displayed using DateTime methods.
I don't have any problem with $c->stash, only with $c->flash.
CONTROLLER
. . sub show_rsvp_POST :Local{ my ($self, $c) = @_; my $model = $c->model( 'RSVP' ); my $params = $c->req->params; my $rsvps = $model->srch_user_info( $params->{ 'srchuser' } ); if($individualRSVP) { $c->flash->{ 'rsvps' } = $rsvps; $c->response->redirect("show_individual_rsvp"); return; } else { $c->flash->{ 'error' } = "There are no users with with that na +me"; $c->response->redirect("show_rsvplist"); return; } } . .
$rsvps is an array of database objects. It contains a DateTime field called rsvpdate. I am using a $c-flash, because I am redirecting the data to a different View, called show_rsvplist.
When I loop through each row to display, it will display the data, when I don't include the rsvpdate. Howwever, when I include the rsvpdate column, I use the DateTime method to display that data
as follows:
MASON TEMPLATE
. . <table> <tr> <td>Name</td> <td>RSVP Date</td> <tr> % foreach my $rsvp (@$rsvps) { <tr> <td><% $rsvp->name %></td> <td><% $rsvp->rsvpdate-mdy('/') %></td> <tr> % } </table> . . <%init> my $rsvps = $c->flash->{ 'rsvps' }; </%init>
As I mentioned, when $c->stash is used, I don't have problems with DateTime objects. But, I need to use the $c->flash because I am calling a different view with a redirect.
When I attempt to display the datetime object with $c-flash, I get the following message:
DBIx::Class::ResultSource::schema(): Unable to perform storage-dependent operations with a detached result source (source 'VRsvps' is not associated with a schema). You need to use $schema->thaw() or manually set $DBIx::Class::ResultSourceHandle::thaw_schema while thawing.....
It suggest that I am not associating the database table with a schema. That is not the case at all.
If anyone has experienced this problem, please help. Thanks.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: How To Pass A DateTime Object in $c->flash
by Your Mother (Archbishop) on May 04, 2016 at 00:22 UTC | |
by phildeman (Scribe) on May 04, 2016 at 11:07 UTC |