class Informativo < ApplicationRecord self.table_name = "informativo" self.primary_key = "Idinformativo" has_and_belongs_to_many :tags before_save :meta def temas Tema.where("cod_tema = #{self.tema1} or cod_tema = #{self.tema2} or cod_tema = #{self.tema3}").map(&:tema) end def as_markdown html = HTMLPage.new :contents => self.Descricao html.markdown end def to_html Redcarpet::Markdown.new(Redcarpet::Render::HTML.new).render(self.markdown) end private def meta #expire_page action: "show", id: params[:list][:id] self.Datainc = DateTime.now unless self.Datainc end end