Sha256: 27e1acd8c07f26dd0af68975bc4e20d4b396f5d8b9c8880105e590ef8fe7187f
Contents?: true
Size: 1.19 KB
Versions: 2
Compression:
Stored size: 1.19 KB
Contents
class InquirySweeper < ActionController::Caching::Sweeper observe :spud_inquiry_form,:spud_inquiry_form_field def before_save(record) if record.is_a?(SpudInquiryForm) @old_name = record.name_was else @old_name = nil end end def after_save(record) if record.is_a?(SpudInquiryFormField) reset_cms_pages(record.spud_inquiry_form) else reset_cms_pages(record) end end def after_destroy(record) if record.is_a?(SpudInquiryFormField) reset_cms_pages(record.spud_inquiry_form) else reset_cms_pages(record) end end private def reset_cms_pages(record) if defined? Spud::Cms::Engine #Is CMS Being Used? values = [record.name] values << @old_name if !@old_name.blank? SpudPageLiquidTag.where(:tag_name => "inquiry",:value => values).includes(:attachment).each do |tag| partial = tag.attachment partial.postprocess_content partial.save page = nil if(partial.attributes.has_key? 'spud_page') page = partial.try(:spud_page) end if page.blank? == false page.updated_at = Time.now.utc page.save end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
spud_inquiries-0.9.5 | app/observers/inquiry_sweeper.rb |
spud_inquiries-0.9.3 | app/observers/inquiry_sweeper.rb |