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.


In reply to How To Pass A DateTime Object in $c->flash by phildeman

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.