Sha256: 9e835ed419442f1b84f64f8a4f82e42438c082939bf8388c4a58796331847cf7

Contents?: true

Size: 901 Bytes

Versions: 1

Compression:

Stored size: 901 Bytes

Contents

module Landable
  class TemplateRevision < ActiveRecord::Base
    include Landable::TableName

    @ignored_template_attributes = %w(editable created_at updated_at published_revision_id file thumbnail_url is_layout is_publishable audit_flags deleted_at)
    class << self
      attr_accessor :ignored_template_attributes
    end

    belongs_to :template, inverse_of: :revisions
    belongs_to :author

    def template_id=(id)
      # set the value
      self[:template_id] = id

      # copy attributes from the template
      self.name          = template.name
      self.body          = template.body
      self.description   = template.description
      self.category_id   = template.category_id
      self.slug          = template.slug
    end

    def publish!
      update_attribute :is_published, true
    end

    def unpublish!
      update_attribute :is_published, false
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
landable-1.14.0 app/models/landable/template_revision.rb