Class: DcNews

Inherits:
Object
  • Object
show all
Includes:
DcSeoConcern, Mongoid::Document, Mongoid::Timestamps
Defined in:
app/models/dc_news.rb

Overview

Schema information

Collection name: dc_news : News

_id                  BSON::ObjectId       _id
created_at           Time                 Time of creation
updated_at           Time                 updated_at
subject              String               Subject of the news
body                 String               Body
active               Mongoid::Boolean     Active
link                 String               Link to blog entry
valid_from           Date                 valid_from
valid_to             Date                 valid_to
categories           Array                categories
created_by           BSON::ObjectId       ID of the creator
created_by_name      String               Name of the creator
dc_replies           Embedded:DcReply     dc_replies

Instance Method Summary collapse

Instance Method Details

#do_before_saveObject

Update link when left blank.



73
74
75
76
77
78
79
80
# File 'app/models/dc_news.rb', line 73

def do_before_save
  if self.link.blank?
    self.link = UnicodeUtils.downcase(DcPage.clear_link(self.subject)) + Time.now.strftime('-%Y-%m-%d')
  end
  if self.created_by_name.nil?
    self.created_by_name = DcUser.find(self.created_by).name
  end
end