Skip to content
Lance Pollard edited this page Sep 24, 2012 · 1 revision

App.User = T.M.extend({ firstName: T.M.field('String'), lastName: T.M.field('String'), posts: T.M.hasMany('Post'), recent: T.M.scope().gte('createdAt', -> _(2).days().ago().toDate()) });

App.UsersController = Tower.Controller.extend({ all: App.User, recent: App.User.recent().refreshInterval(60),

index: function(request, response, callback) { var users = this.get('all');

this.render('index', {users: users});

},

create: function() { App.User.create(this.params.user, function(error, user) { this.render(); }); } });

App.routes(function() { this.resources('users'); });

Tower.Model.extend = (object) -> @_super(object)

for key, value of object if value instanceof Tower.Model.Field @fields.push(key)

Tower.Controller.extend = (object) -> @_super(object)

for key, value of object if value instanceof Tower.Model.Scope

else if value instanceof Tower.Model.Cursor
Clone this wiki locally