Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

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

by zby (Vicar)
on Oct 21, 2008 at 07:08 UTC ( [id://718385]=note: print w/replies, xml ) Need Help??


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

# Default route $r->route('/:controller/:action/:id') ->to(controller => 'example', action => 'welcome', id => 1);
Do you need to add non default routes? Or is this $r->route('/:controller/:action/:id') part enough to declare the parsing of the uri and routing the the appriopriate controller and action? If my assumptions are right - then does ->to really mean ->default?

Replies are listed 'Best First'.
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
    Nope, you don't have to define other routes if you don't want to, ->to is in fact synonymous to ->default.
      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)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://718385]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (7)
As of 2024-04-23 13:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found