Sha256: 1f623e56a16f3ca874450f6cd7264ff340b7d14daf2c21a2e6a3cb0a3b575e6a

Contents?: true

Size: 778 Bytes

Versions: 7

Compression:

Stored size: 778 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, :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

7 entries across 7 versions & 1 rubygems

Version Path
bit_core-1.2.2 app/models/bit_core/slide.rb
bit_core-1.2.1 app/models/bit_core/slide.rb
bit_core-1.2.0 app/models/bit_core/slide.rb
bit_core-1.1.6 app/models/bit_core/slide.rb
bit_core-1.1.5 app/models/bit_core/slide.rb
bit_core-1.1.4 app/models/bit_core/slide.rb
bit_core-1.1.3 app/models/bit_core/slide.rb