Sha256: 0cf857be554906af2dcc1607438794b8e620e88be9b3fdbbe3c078c9f45d0c1a

Contents?: true

Size: 732 Bytes

Versions: 2

Compression:

Stored size: 732 Bytes

Contents

module Guts
  # Type model
  class Type < ActiveRecord::Base
    extend FriendlyId
    include NavigatableConcern
    include TrackableConcern
    include MultisiteScopeConcern

    validates :title, presence: true, length: { minimum: 3 }

    has_many :contents
    has_many :media, as: :filable, dependent: :destroy
    has_many :metafields, as: :fieldable, dependent: :destroy
    has_many :tracks, as: :object

    friendly_id :title, use: [:slugged, :scoped, :finders], scope: :site_id
    navigatable :title, format: ':title'
    trackable :create, :update, :destroy, fields: [:title]

    # Updates slug if title changes
    # @return [Boolean]
    def should_generate_new_friendly_id?
      title_changed?
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
guts-1.4.0 app/models/guts/type.rb
guts-1.3.6 app/models/guts/type.rb