I don’t have time to write test code but I think see the problem. You can only use a flash entry once. It’s gone—removed from the session—after that. The entire point is it cannot persist past a single use. Put it in the stash instead—unless you need it to persist past a redirect or something—and you should be fine. And just to be clear, this is actually a Catalyst question, not a DBIx::Class question. The flash/stash is part of the Catalyst context and its session.

More detail, when you do if $c->flash->{bio}, you just used it so it’s gone by the time you get to the assignment. Also note, you should never put a conditional on an (update: variable declarative) assignment statement. It can behave strangely.

# Unpredictable- my $x = 1 if $y; # Safe- my $x; $x = 1 if $y;

Update in case you do need it as flash, untested–

<%init> my $bio = $c->flash->{'bio'}; </%init> % if ( $bio ) { <p>My name is <% $bio->name |h %><br /> My residence is at <% $bio->address |h %></p> % }

Update, added HTML escape filters. Been ages since I did Mason. :P NEVER trust user input.


In reply to Re: $c->flash Not Dereferencing Data Objects by Your Mother
in thread $c->flash Not Dereferencing Data Objects 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.