Sha256: b2ae3558dfe44bbbfb422584a21178e7976893cf9b3807286c3d2e54ad224efd

Contents?: true

Size: 854 Bytes

Versions: 4

Compression:

Stored size: 854 Bytes

Contents

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

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

    belongs_to :site
    belongs_to :type
    belongs_to :user, required: false
    has_many :categorizations
    has_many :categories, through: :categorizations
    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 :'type.title', :title, format: '[:type.title] :title'

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

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
guts-2.1.0 app/models/guts/content.rb
guts-2.0.2 app/models/guts/content.rb
guts-2.0.1 app/models/guts/content.rb
guts-2.0.0 app/models/guts/content.rb