Class: Content

Inherits:
ActiveRecord::Base
  • Object
show all
Includes:
Housekeeping
Defined in:
app/models/content.rb

Direct Known Subclasses

OtuContent

Instance Method Summary collapse

Methods included from Housekeeping

#has_polymorphic_relationship?

Instance Method Details

#publishObject



17
18
19
20
21
22
23
24
25
26
27
# File 'app/models/content.rb', line 17

def publish
  to_publish = {
    otu: self.otu,
    topic: self.topic,
    text: self.text, 
  }

  self.public_content.delete if self.public_content
  self.public_content = PublicContent.new(to_publish)
  self.save
end

#published?Boolean



13
14
15
# File 'app/models/content.rb', line 13

def published? 
  self.public_content
end

#unpublishObject



29
30
31
# File 'app/models/content.rb', line 29

def unpublish
  self.public_content.destroy
end