Sha256: 46dbe69931729f557ce3e3efa46b5ff4308ef69dc1a719afc4a93a363ea88ed0

Contents?: true

Size: 785 Bytes

Versions: 3

Compression:

Stored size: 785 Bytes

Contents

require "redcarpet"

module BitCore
  # A page of "static" or presentational content (as opposed to data capture).
  class Slide < ActiveRecord::Base
    belongs_to :slideshow,
               class_name: "BitCore::Slideshow",
               foreign_key: :bit_core_slideshow_id,
               inverse_of: :slides

    validates :title, :body, :position, presence: true
    validates :position, numericality: { greater_than_or_equal_to: 1 }
    validates :position, uniqueness: { scope: :bit_core_slideshow_id }

    def render_body
      return "" if body.nil?

      Redcarpet::Markdown.new(
        Redcarpet::Render::HTML.new(
          filter_html: true,
          safe_links_only: true
        ),
        space_after_headers: true
      ).render(body).html_safe
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
bit_core-1.1.2 app/models/bit_core/slide.rb
bit_core-1.1.1 app/models/bit_core/slide.rb
bit_core-1.1.0 app/models/bit_core/slide.rb