[Catalyst] Catalyst vs. Rails on the wiki

Sebastian Riedel sri at oook.de
Sat Aug 20 06:32:16 CEST 2005


Am 18.08.2005 um 02:14 schrieb Philip Edelbrock:

>
> (nuts... I first sent this from the wrong account ;')
>
> Well, I posted it on the Rails mail list for review.  Reception was
> pretty good.  There are some changes being made to the page (as
> expected).  The Rails side is getting a little heavy, but the changes
> seem pretty sensible thus far.

Thanks for the good comparison, but what i still miss are some code  
examples.
We are especially proud of the elegant and fast dispatcher, having  
the uri -> method mapping right in your controller makes things much  
easier imo.

1. Plain /controller/method/attr mapping

     package MyApp::C::Foo;

     sub bar : Local {
         my ( $self, $c, @attrs ) = @_;
     }

     1;

vs.

     class FooController < ApplicationController

         def bar
         end

     end


2. Toplevel mapping, matches /bar

     package MyApp::C::Foo;

     sub bar : Global {
         my ( $self, $c, @attrs ) = @_;
     }

     1;

vs.

     class FooController < ApplicationController

         def bar
         end

     end

     ActionController::Routing::Routes.draw do |map|

         map.connect "bar", :controller => "foo", :action => "bar"



3. Real world mapping, matches /index.html

     package MyApp::C::Foo;

     sub bar : Path('/index.html') {
         my ( $self, $c, @attrs ) = @_;
     }

     1;

vs.

     class FooController < ApplicationController

         def bar
         end

     end

     ActionController::Routing::Routes.draw do |map|

         map.connect "index.html", :controller => "foo", :action =>  
"bar"


4. Regex mapping, matches everything that ends in .html (and captures  
the matching snippet)

     package MyApp::C::Foo;

     sub bar : Regex('^(*.\.html)$') {
         my ( $self, $c, @attrs ) = @_;
     }

     1;

vs.

     Not sure if this is possible in Routes



--
sebastian

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.rawmode.org/pipermail/catalyst/attachments/20050820/4ab4c717/attachment.htm


More information about the Catalyst mailing list