假设我有两个模型拥有相同的回调函数:
class Entry < ActiveRecord::Base
belongs_to :patient
validates :text, presence: true
after_validation :normalizeDate
def normalizeDate
self.created_at = return_DateTime(self.created_at)
end
end
class Post < ActiveRecord::Base
after_validation :normalizeDate
def normalizeDate
self.created_at = return_DateTime(self.created_at)
end
end
我应该把共享回调代码放在哪里?谢谢
def normalizeDate
self.created_at = return_DateTime(self.created_at)
end