[dancer-users] passing a variable to a new subroutine route

Richard Reina gatorreina at gmail.com
Mon Aug 24 16:52:03 BST 2015


Hi WK,

Thank you very much for the reply. Before I saw this came up with this
solution to pass the variable to the other sub/template:

  # take them to the add_sport (but with the id no)
    hook 'before' => sub {
          var S_id => $select_id;
          request->path('/sport_add')
    };

    redirect '/sport_add';

It actually worked but I was wondering if doing it this way with hook and
redirect is a bad idea?  Also, I was wondering why it's a bad idea to print
input from dancer to the console?  Does it produce a security vulnerability
or is it merely disruptive to dancer?

Thanks


2015-08-23 18:08 GMT-05:00 WK <wanradt at gmail.com>:

> 2015-08-23 22:31 GMT+03:00 Richard Reina <gatorreina at gmail.com>:
>
> > PLEASE IGNORE MY POST SENT MOMENTS AGO. I WAS NOT FINISHED TYPING.
>
> I think, in your previous post you were much closer to the needed pattern.
>
> >  post '/mypage' => sub { # let user make a selection
> >
> >     my $select_id = params->{Sselect};
> >
> >     print "\n\nLooks Like They Selected No: $select_id\n\n";
>
> Printing here is not good idea.
>
> >     # look up DB records corresponding to $select_id;
> >
> >     # store them in hash refrence $sel_ref
>
> Nope. If you need to store users posted data in DB, you redirect them
> afterwards to another route (/sport_add/$sele) and look up from DB
> there (get your $self_ref).
>
> If you don't need to store, you don't have need for post-route at all.
>
> And your get-route would look like:
>
> get '/sport_add/:id' => sub {
>   my ( $id ) = splat;
>   # DB query by ID
>   # template call ...
> }
>
> Hope it helps a bit
>
> wbr,
> --
> Kõike hääd,
>
> Gunnar
> _______________________________________________
> dancer-users mailing list
> dancer-users at dancer.pm
> http://lists.preshweb.co.uk/mailman/listinfo/dancer-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.preshweb.co.uk/pipermail/dancer-users/attachments/20150824/1b6cfa81/attachment.html>


More information about the dancer-users mailing list