app/models/landable/template.rb in landable-1.9.0.rc1 vs app/models/landable/template.rb in landable-1.9.0.rc2

- old
+ new

@@ -10,12 +10,15 @@ validates_uniqueness_of :name, case_sensitive: false validates_uniqueness_of :slug, case_sensitive: false belongs_to :published_revision, class_name: 'Landable::TemplateRevision' + has_many :audits, class_name: 'Landable::Audit', as: :auditable has_many :revisions, class_name: 'Landable::TemplateRevision' + has_and_belongs_to_many :pages, join_table: Page.templates_join_table_name + before_save -> template { template.is_publishable = true unless template.published_revision_id_changed? } def deactivate @@ -36,9 +39,19 @@ def publish!(options) transaction do published_revision.unpublish! if published_revision revision = revisions.create! options update_attributes!(published_revision: revision, is_publishable: false) + + # Republish Templates Pages Last Page Revision + republish_associated_pages(options) + end + end + + def republish_associated_pages(options) + options[:template] = self.name + pages.each do |page| + page.republish!(options) if page.published? end end def revert_to!(revision) self.name = revision.name