class ExternalArticle

Public Instance Methods

to_s() click to toggle source
# File lib/buweb/external_article.rb, line 32
def to_s
  title
end

Private Instance Methods

author_or_source_author() click to toggle source
# File lib/buweb/external_article.rb, line 37
def author_or_source_author
  unless source_author.present? || author.present?
    errors.add :base, 'Must have an author or a external_blog author from external site.'
  end
end
set_slug() click to toggle source

sets slug from title

# File lib/buweb/external_article.rb, line 44
def set_slug
  if title?
    appendage = nil
    while ::ExternalArticle.where(slug: "#{title.parameterize}#{appendage}").present?
      appendage.nil? ? appendage = 1 : appendage += 1
    end
    self.slug = "#{title.parameterize}#{appendage}"
  end
end