Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses

Re^2: Mojo 0.7 released (Perl on Rails in 150 lines of code)

by sri (Vicar)
on Oct 21, 2008 at 08:58 UTC ( #718411=note: print w/replies, xml ) Need Help??

in reply to Re: Mojo 0.7 released (Perl on Rails in 150 lines of code)
in thread Mojo 0.7 released (Perl on Rails in 150 lines of code)

Nope, you don't have to define other routes if you don't want to, ->to is in fact synonymous to ->default.

Replies are listed 'Best First'.
Re^3: Mojo 0.7 released (Perl on Rails in 150 lines of code)
by zby (Vicar) on Oct 21, 2008 at 09:05 UTC
    OK - so one more question. In the code above - does ->to add that default route to $r (i.e. globally) - or does it only add it to uris that can be parsed as '/:controller/:action/:id' (i.e. to the just added route)?
      ->route will create a new route object, which has a method ->to that sets some attributes in the object.
      There is no hidden magic and they should not touch parent or child routes, but default values (and captures) will be forwarded to child routes when matching a path.
      # /foo my $x = $r->route('/foo')->to(controller => 'bar'); # /foo/* $x->route('/:action')->to(action => 'test');
      This would be a nested route example where defaults and captures get forwarded. (controller => 'bar' in this case)
        Nice. Although without the explanation I would read $x->route('/:action')->to(action => 'test'); as meaning that now everything would go to test. Even now I am not so sure if I understood it correctly - and that it only means that uris without a matching action part would end up there.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://718411]
marioroy Updated Re^3: RFC: Compiling Gtk+ stack on windows with strawberry perl. Also tested Gtk2 installation on Strawberry Perl v5.22.3.1. Installing Tk and Tk::Zinc works fine on Perl v5.22.3.1.
[marioroy]: Hi karlgoethebier. Folks can comment feasibly if asking the review via a meditation (imho).

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (6)
As of 2017-09-24 09:36 GMT
Find Nodes?
    Voting Booth?
    During the recent solar eclipse, I:

    Results (273 votes). Check out past polls.