module DraftUtils::InstanceMethods

Public Instance Methods

draft() click to toggle source
# File app/models/draft_utils.rb, line 38
def draft
  if @draft.nil?
    self.published_at.nil? ? "1" : "0"
  else
    @draft
  end
end
draft=(val) click to toggle source
# File app/models/draft_utils.rb, line 34
def draft=(val)
  @draft = val
end
sync_draft_and_published_at() click to toggle source

Garantiza que las noticias en borrador no tienen fecha de publicación. Se llama desde before_save

# File app/models/draft_utils.rb, line 26
def sync_draft_and_published_at
  if self.draft == "1"
    self.published_at = nil
  else
    self.published_at = Time.zone.now if self.published_at.nil?
  end
end