Sha256: 980d42578841276a6339094412509229eacafd00be84cb85526e193fdb6bb519

Contents?: true

Size: 552 Bytes

Versions: 10

Compression:

Stored size: 552 Bytes

Contents

# Belongs to a {Page}. A chunk of presentable content, either made up of plain text or HTML.
class ContentBlock < ActiveRecord::Base
  extend FriendlyId
  friendly_id :title, use: :slugged

  validates :title, :slug, uniqueness: true
  validates :title, presence: true
  validates :slug, presence: true, on: :update

  belongs_to :page

  default_scope includes(:page).order('pages.title')

  # @return [String] a string of plain text or render-safe HTML.
  def render
    if allow_html
      content.html_safe
    else
      content
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
manifest-rails-0.2.8 app/models/content_block.rb
manifest-rails-0.2.7 app/models/content_block.rb
manifest-rails-0.2.6 app/models/content_block.rb
manifest-rails-0.2.5 app/models/content_block.rb
manifest-rails-0.2.4 app/models/content_block.rb
manifest-rails-0.2.3 app/models/content_block.rb
manifest-rails-0.2.2 app/models/content_block.rb
manifest-rails-0.2.1 app/models/content_block.rb
manifest-rails-0.2.0 app/models/content_block.rb
manifest-rails-0.1.3 app/models/content_block.rb