ref: master
plugins/tolerance_time/lib/ext/article.rb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
require_dependency 'article' class Article after_create do |article| ToleranceTimePlugin::Publication.create!(:target => article) if article.published end before_save do |article| if article.published_changed? if article.published ToleranceTimePlugin::Publication.create!(:target => article) else publication = ToleranceTimePlugin::Publication.find_by target: article publication.destroy if publication.present? end end end before_destroy do |article| publication = ToleranceTimePlugin::Publication.find_by target: article publication.destroy if publication.present? end end |