Class: HasContent::Record
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- HasContent::Record
- Defined in:
- lib/has_content/record.rb
Instance Method Summary collapse
- #allowed_names ⇒ Object
-
#initialize ⇒ Record
constructor
Contents are only ever instantiated by has_content assoc, and it’s convenient for them to always refer (for links to content etc).
- #to_s ⇒ Object
Constructor Details
#initialize ⇒ Record
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_names ⇒ Object
26 27 28 |
# File 'lib/has_content/record.rb', line 26 def allowed_names owner.try(:content_names) || [] end |
#to_s ⇒ Object
22 23 24 |
# File 'lib/has_content/record.rb', line 22 def to_s content end |