call postgres notify after any post change

This commit is contained in:
r888888888
2016-05-06 16:49:36 -07:00
parent 27f53fa5db
commit 0b214a834b

View File

@@ -13,6 +13,7 @@ class Post < ActiveRecord::Base
after_save :update_parent_on_save
after_save :apply_post_metatags
after_create :update_iqdb_async
after_commit :pg_notify
before_save :merge_old_changes
before_save :normalize_tags
before_save :update_tag_post_counts
@@ -1342,6 +1343,10 @@ class Post < ActiveRecord::Base
revert_to(target)
save!
end
def pg_notify
execute_sql("notify changes_posts, '#{id}'")
end
end
module NoteMethods
@@ -1707,6 +1712,18 @@ class Post < ActiveRecord::Base
self.tag_string = tags.join(" ")
save
end
def update_column(name, value)
ret = super(name, value)
pg_notify
ret
end
def update_columns(attributes)
ret = super(attributes)
pg_notify
ret
end
end
Post.connection.extend(PostgresExtensions)