Issues with Templates and Data

41 views
Skip to first unread message

Ali

unread,
Nov 8, 2011, 1:00:01 PM11/8/11
to mojol...@googlegroups.com
Hey Everyone,

New to the Mojo world and working on my first app but I am hitting an
issue that has me totally confused that I have been working on for
several days trying various things to try to figure out what the
problem is. I think I have been able to narrow the issue down to the
template and its access to stash data. Here is what I have so far I
have a controller samples.pm which has a method named pe. I created a
model which does a query on a table fetches the rows (I set a limit of
10) and pushes them onto an array in the model then returns that array
to samples->pe. I then do a log message and dump the values to make
sure its all there. I throw that on the stash and try to loop through
the data and I run into some issues. One of the issues I run into is
that I cant get my template to ever display 10 rows. If I lower my
query to return 3 items it works. I even put a dump statement inside
my templates to dump the data and it only dumps the correct data when
it all works fine which is when I lower the query to 3 items. I have
tried to manually pushed 5 items onto the array and that works fine
but 5 items wont work if its from the DB. But here is another weird
thing if I just render my data to json it ALWAYS shows me the correct
values even if I do a query of 10. Another weird issue is that
sometimes I change between some query variations and manual data and
the template will still show the old data and yes I have cleared
browser cache, restarted the server, shift+refresh. So to me it seems
like something is happening at the template level that either I am not
understanding correctly or I am just doing totally wrong. Any advice
or suggestions would be greatly appreciated. Here is what my template
looks like.

% my $inputs = flash 'inputs';
total rows: <%#= scalar @{$inputs} %>
<table border="1">
<tr>
<thead>
<tr>
<td><b>Input ID</b></td>
<td><b>Target</b></td>
<td><b>State</b></td>
<td><b>State Description</b></td>
<td><b>URL</b></td>
<td><b>Filename</b></td>
<td><b>Content ID</b></td>
</tr>
</thead>
<tbody>
% foreach my $input (@{$inputs})
% {
<tr>
<td><%= $input->{input_id} %></td>
<td><%= $input->{target} %></td>
<td><%= $input->{state} %></td>
<td><%= $input->{state_desc} %></td>
<td><%== $input->{u_url} %></td>
<td><%== $input->{f_filename} %></td>
<td><%= $input->{c_content_id} %></td>
</tr>
% }
</tbody>
</tr>
</table>

<%= dumper($inputs) %>

Benjamin Hitz

unread,
Nov 8, 2011, 1:02:55 PM11/8/11
to mojol...@googlegroups.com
Are you sure you want flash not stash?

Ben

> --
> You received this message because you are subscribed to the Google Groups "Mojolicious" group.
> To post to this group, send email to mojol...@googlegroups.com.
> To unsubscribe from this group, send email to mojolicious...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/mojolicious?hl=en.
>

--
Ben Hitz
Senior Scientific Programmer ** Saccharomyces Genome Database ** GO Consortium
Stanford University ** hi...@stanford.edu


Ali

unread,
Nov 8, 2011, 3:17:44 PM11/8/11
to mojol...@googlegroups.com
Oh man! Thank you so much for that. I copied that part of my code from
some of the examples I saw and never even thought about that as
causing my issues!!! Now its actually working sanely.
Reply all
Reply to author
Forward
0 new messages