app/models/landable/template.rb in landable-1.7.1.rc1 vs app/models/landable/template.rb in landable-1.8.0

- old
+ new

@@ -1,9 +1,13 @@ module Landable class Template < ActiveRecord::Base include Landable::TableName + include Landable::Librarian + # attributes + attr_accessor :temp_author + validates_presence_of :name, :slug, :description validates_uniqueness_of :name, case_sensitive: false validates_uniqueness_of :slug, case_sensitive: false @@ -11,9 +15,15 @@ has_many :revisions, class_name: 'Landable::TemplateRevision' before_save -> 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") + + super + end def name= val self[:name] = val self[:slug] ||= (val && val.underscore.gsub(/[^\w_]/, '_').gsub(/_{2,}/, '_')) end