Sha256: e67be35fd8ff9f0a44b2d862fa7bcee7c75eb345e9631316ce10039d020b489b

Contents?: true

Size: 678 Bytes

Versions: 4

Compression:

Stored size: 678 Bytes

Contents

class Snippet < ActiveRecord::Base
  
  # Default Order
  default_scope {order('name')}

  # Accessible
  attr_accessible :lock_version, :name, :content, :site_id

  # Associations
  belongs_to :created_by, :class_name => 'User'
  belongs_to :updated_by, :class_name => 'User'

  # Validations
  validates_presence_of :name
  validates_length_of :name, :maximum => 100
  validates_length_of :filter_id, :maximum => 25, :allow_nil => true
  validates_format_of :name, :with => %r{\A\S*\z}
  validates_uniqueness_of :name
  
  object_id_attr :filter, TextFilter

  def after_initialize
    self.filter_id ||= TrustyCms::Config['defaults.snippet.filter'] if new_record?
  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
trusty-snippets-extension-3.0.0 app/models/snippet.rb
trusty-snippets-extension-2.0.7 app/models/snippet.rb
trusty-snippets-extension-2.0.6 app/models/snippet.rb
trusty-snippets-extension-2.0.5 app/models/snippet.rb