Sha256: db0c5c12eab55433001c06a87bffd1d5f45622867b7850837e87dd3cc63a12cd

Contents?: true

Size: 630 Bytes

Versions: 27

Compression:

Stored size: 630 Bytes

Contents

class Content < ActiveRecord::Base
  has_paper_trail
  # belongs_to :contentable, :polymorphic => true
  validate :name, :unique => true
  acts_as_indexed :fields => [:body, :key, :note]
  include Soapbox::Content if File.exists? "app/models/soapbox/content.rb"
  
  # Content[name]
  def self.[](key)
    find_or_create_by_key(key).try(:body)
  end
  
  def self.named(key)
    find_or_create_by_key(key)
  end
  
  def self.[]=(key, v)
    setting = find_or_create_by_key(key)
    setting.value = (v ? v : "")
    setting.save
    setting.value
  end
  
  # usage @page.contents[:sidebar]
  # usage @page.contents[:summary]
end

Version data entries

27 entries across 27 versions & 1 rubygems

Version Path
soapbox-0.3.1 app/models/content.rb
soapbox-0.3.0 app/models/content.rb
soapbox-0.2.24 app/models/content.rb
soapbox-0.2.23 app/models/content.rb
soapbox-0.2.21 app/models/content.rb
soapbox-0.2.20 app/models/content.rb
soapbox-0.2.18 app/models/content.rb
soapbox-0.2.16 app/models/content.rb
soapbox-0.2.15 app/models/content.rb
soapbox-0.2.14 app/models/content.rb
soapbox-0.2.12 app/models/content.rb
soapbox-0.2.11 app/models/content.rb
soapbox-0.2.10 app/models/content.rb
soapbox-0.2.9 app/models/content.rb
soapbox-0.2.8 app/models/content.rb
soapbox-0.2.7 app/models/content.rb
soapbox-0.2.6 app/models/content.rb
soapbox-0.2.5 app/models/content.rb
soapbox-0.2.4 app/models/content.rb
soapbox-0.2.3 app/models/content.rb