Batman.App Routing
The Batman routing DSL is similar to Rails 3's routing DSL. It is oriented around the notion of a resource:
-
@route
@routedefines a custom route and can be pointed to a controller action directly. For example:class window.Example extends Batman.App @route 'comments', 'pages#comments' class Example.PagesController extends Batman.Controller comments: ->Would result in
/commentsbeing added to the routing map, pointed toPagesController#comments. -
@resources(resourceName : String[, otherResourceNames... : String][, options : Object][, scopedCallback : Function])
-
@member
@memberdefines a routable action you can call on a specific instance of a member of a collection resource. For example, if you have a collection ofPageresources, and a user can post a comment on a specific page:class window.Example extends Batman.App @resources 'pages', -> @member 'comment' class Example.PagesController extends Batman.Controller comment: (params) ->Would result in
/pages/:id/commentbeing added to the routing map, pointed toPagesController#comment. -
@collection
@collectionis similar to@memberin that it adds routable actions to a@resourcesset of routes. In this case the action would apply to the entire collection. For example, if you have a list of spam comments made across all yourPageresources:class window.Example extends Batman.App @resources 'pages', -> @collection 'spam_comments' class Example.PagesController extends Batman.Controller comments: ->Would result in
/pages/spam_commentsbeing added to the routing map, pointed toPagesController#spam_comments. -
@root
@rootdefines the root controller and action to be used when visiting the base application URL. For example:class window.Example extends Batman.App @root 'pages#index' class Example.PagesController extends Batman.Controller index: ->Would result in
/being pointed toPagesController#index.
