Sha256: c970bf7a3875ffa0cdd8e25307d9c4b5a7fc19a09f2a3ba4f10656bad1bd55d6

Contents?: true

Size: 442 Bytes

Versions: 10

Compression:

Stored size: 442 Bytes

Contents

class PagePart < ActiveRecord::Base

  belongs_to :page

  validates :title, :presence => true
  alias_attribute :content, :body

  def to_param
    "page_part_#{self.title.downcase.gsub(/\W/, '_')}"
  end

  before_save :normalise_text_fields

protected
  def normalise_text_fields
    unless self.body.blank? or self.body =~ /^\</
      self.body = "<p>#{self.body.gsub("\r\n\r\n", "</p><p>").gsub("\r\n", "<br/>")}</p>"
    end
  end

end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
refinerycms-0.9.8.9 vendor/refinerycms/pages/app/models/page_part.rb
refinerycms-0.9.8.8 vendor/refinerycms/pages/app/models/page_part.rb
refinerycms-0.9.8.7 vendor/refinerycms/pages/app/models/page_part.rb
refinerycms-0.9.8.6 vendor/refinerycms/pages/app/models/page_part.rb
refinerycms-0.9.8.5 vendor/refinerycms/pages/app/models/page_part.rb
refinerycms-0.9.8.4 vendor/refinerycms/pages/app/models/page_part.rb
refinerycms-0.9.8.3 vendor/refinerycms/pages/app/models/page_part.rb
refinerycms-0.9.8.2 vendor/refinerycms/pages/app/models/page_part.rb
refinerycms-0.9.8.1 vendor/refinerycms/pages/app/models/page_part.rb
refinerycms-0.9.8 vendor/refinerycms/pages/app/models/page_part.rb