2014年9月24日 星期三

[Rails] Use ActiveModel 's Callbacks .

使用結果如下:

class TestCallback extend ActiveModel::Callbacks define_model_callbacks :create def create run_callbacks :create do puts 'Run run_callback' end end before_create :action_before_create def action_before_create puts 'Run action_before_create' end end TestCallback.new.create Result: Run action_before_create Run run_callback

【下列文章您可能也有興趣】

沒有留言: