File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -20,7 +20,7 @@ class Article
2020 belongs_to :user
2121
2222 # Core filters
23- before :update , :set_published_permalink
23+ before :save , :set_published_permalink
2424 after :create , :set_create_activity
2525 after :update , :set_update_activity
2626
@@ -47,25 +47,19 @@ def set_published_permalink
4747 end
4848
4949 def set_create_activity
50- if new_record?
51- a = Activity . new
52- a . message = "Article \" #{ self . title } \" created"
53- a . save
54- end
50+ a = Activity . new
51+ a . message = "Article \" #{ self . title } \" created"
52+ a . save
5553 end
5654
5755 def set_update_activity
58- unless new_record?
59- a = Activity . new
60- a . message = "Article \" #{ self . title } \" updated"
61- a . save
62- end
56+ a = Activity . new
57+ a . message = "Article \" #{ self . title } \" updated"
58+ a . save
6359 end
6460
6561 def fire_before_create_event
66- if new_record?
67- Hooks ::Events . before_create_article ( self )
68- end
62+ Hooks ::Events . before_create_article ( self )
6963 end
7064
7165 def fire_before_update_event
@@ -78,9 +72,7 @@ def fire_before_save_event
7872 end
7973
8074 def fire_after_create_event
81- if new_record?
82- Hooks ::Events . after_create_article ( self )
83- end
75+ Hooks ::Events . after_create_article ( self )
8476 end
8577
8678 def fire_after_update_event
You can’t perform that action at this time.
0 commit comments