Class: HasContent::Record

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
lib/has_content/record.rb

Instance Method Summary collapse

Constructor Details

#initializeRecord

Contents are only ever instantiated by has_content assoc, and it’s convenient for them to always refer (for links to content etc). If there is a validation problem, the save will fail silently (which is fine)



17
18
19
20
# File 'lib/has_content/record.rb', line 17

def initialize(*)
  super
  save if new_record? && owner_persisted?
end

Instance Method Details

#allowed_namesObject



26
27
28
# File 'lib/has_content/record.rb', line 26

def allowed_names
  owner.try(:content_names) || []
end

#to_sObject



22
23
24
# File 'lib/has_content/record.rb', line 22

def to_s
  content
end