BUGFIX: raise message bus messages after data is committed

This commit is contained in:
Sam 2014-04-02 12:47:28 +11:00
parent b1c305ce62
commit d2926424d6
1 changed files with 3 additions and 3 deletions

View File

@ -41,7 +41,8 @@ class SiteCustomization < ActiveRecord::Base
end end
end end
after_save do # calls message bus, data must be committed
after_commit(on: :save) do
if stylesheet_changed? if stylesheet_changed?
File.delete(stylesheet_fullpath) if File.exists?(stylesheet_fullpath) File.delete(stylesheet_fullpath) if File.exists?(stylesheet_fullpath)
end end
@ -55,10 +56,9 @@ class SiteCustomization < ActiveRecord::Base
MessageBus.publish "/file-change/#{key}", stylesheet_hash MessageBus.publish "/file-change/#{key}", stylesheet_hash
end end
MessageBus.publish "/header-change/#{key}", header if header_changed? MessageBus.publish "/header-change/#{key}", header if header_changed?
end end
after_destroy do after_commit(on: :destroy) do
if File.exists?(stylesheet_fullpath) if File.exists?(stylesheet_fullpath)
File.delete stylesheet_fullpath File.delete stylesheet_fullpath
end end