Sha256: f804ad5cdbcb15dff581b3e9a0ea8a99a1c1e874a7b77128806498b40e834ea1

Contents?: true

Size: 581 Bytes

Versions: 79

Compression:

Stored size: 581 Bytes

Contents

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

  # 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

79 entries across 79 versions & 1 rubygems

Version Path
trusty-cms-7.0.10 app/models/snippet.rb
trusty-cms-7.0.9 app/models/snippet.rb
trusty-cms-7.0.8 app/models/snippet.rb
trusty-cms-7.0.7 app/models/snippet.rb
trusty-cms-7.0.6 app/models/snippet.rb
trusty-cms-7.0.5 app/models/snippet.rb
trusty-cms-7.0.4 app/models/snippet.rb
trusty-cms-7.0.3 app/models/snippet.rb
trusty-cms-6.3.1 app/models/snippet.rb
trusty-cms-7.0.2 app/models/snippet.rb
trusty-cms-7.0.1 app/models/snippet.rb
trusty-cms-7.0.0 app/models/snippet.rb
trusty-cms-6.3 app/models/snippet.rb
trusty-cms-6.2.1 app/models/snippet.rb
trusty-cms-6.2.2.1 app/models/snippet.rb
trusty-cms-6.2.0 app/models/snippet.rb
trusty-cms-6.1.2 app/models/snippet.rb
trusty-cms-6.1.1 app/models/snippet.rb
trusty-cms-6.0.5 app/models/snippet.rb
trusty-cms-6.0.4 app/models/snippet.rb