Sha256: 26e9db4141cbf649f37041c9e5f186b1faaca1922d14d57dab7c492f7048366d

Contents?: true

Size: 640 Bytes

Versions: 1

Compression:

Stored size: 640 Bytes

Contents

module Slightcms
  class Layout < ActiveRecord::Base
    
    # Change default table name
    set_table_name 'slightcms_layouts'

    # Default order
    default_scope :order => 'name'
  
    # Associations
    has_many :pages, :class_name => "Slightcms::Page"
  
    # Validations
    validates_presence_of :name
    validates_uniqueness_of :name
    validates_presence_of :content
    
    # Create a file accessor
    attr_accessor :file
    
    # Write file to content if file is uploaded
    def file=(uploaded_file)
      unless uploaded_file.nil?
        write_attribute(:content, uploaded_file.read)
      end
    end
  
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
slightcms-0.0.11 lib/app/models/layout.rb