【发布时间】:2013-03-30 10:31:17
【问题描述】:
在 Rails 中我们有生命周期钩子,它允许我们这样做:
class Subscription < ActiveRecord::Base
before_create :record_signup
private
def record_signup
self.signed_up_on = Date.today
end
end
在Spine.js 中是否有最好的方法来完成同样的事情(我需要它来设置一些默认值)?
目前我是这样做的,但也许有更好的方法存在?
class Subscription extends Spine.Model
@record_signup: (self) ->
self.signed_up_on = new Date()
Subscription.bind 'beforeSave', Subscription.record_signup
【问题讨论】:
标签: coffeescript spine.js