app/models/landable/template.rb in landable-1.13.2 vs app/models/landable/template.rb in landable-1.14.0
- old
+ new
@@ -11,18 +11,19 @@
validates_uniqueness_of :slug, case_sensitive: false
before_save :slug_has_no_spaces
belongs_to :published_revision, class_name: 'Landable::TemplateRevision'
+ belongs_to :category, class_name: 'Landable::Category'
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
+ has_and_belongs_to_many :pages, join_table: Page.templates_join_table_name
delegate :count, to: :pages, prefix: true # Returns how many Pages a Template lives in!
- before_save lambda { |template|
+ before_save lambda { |template|
template.is_publishable = true unless template.published_revision_id_changed?
}
def deactivate
publish!(author_id: temp_author.id, notes: 'This template has been trashed')
@@ -59,9 +60,10 @@
def revert_to!(revision)
self.name = revision.name
self.body = revision.body
self.description = revision.description
+ self.category_id = revision.category_id
self.slug = revision.slug
save!
end