Sha256: f9151b9ae8deb01144c52c2fb6a38adb194f0d0dfd11fe69e3ad391b83af6d1e

Contents?: true

Size: 538 Bytes

Versions: 32

Compression:

Stored size: 538 Bytes

Contents

# frozen_string_literal: true

module Thredded
  class MessageboardGroup < ActiveRecord::Base
    has_many :messageboards,
             inverse_of: :group,
             foreign_key: :messageboard_group_id,
             dependent: :nullify

    scope :ordered, -> { order(position: :asc, id: :asc) }
    validates :name, presence: true, uniqueness: true
    validates :position, presence: true, on: :update
    before_save :ensure_position, on: :create

    def ensure_position
      self.position ||= Time.zone.now.to_i
    end
  end
end

Version data entries

32 entries across 32 versions & 2 rubygems

Version Path
thredded-0.16.9 app/models/thredded/messageboard_group.rb
thredded-0.16.8 app/models/thredded/messageboard_group.rb
thredded-0.16.7 app/models/thredded/messageboard_group.rb
thredded-0.16.6 app/models/thredded/messageboard_group.rb
thredded-0.16.5 app/models/thredded/messageboard_group.rb
thredded-0.16.4 app/models/thredded/messageboard_group.rb
thredded-0.16.3 app/models/thredded/messageboard_group.rb
thredded-0.16.1 app/models/thredded/messageboard_group.rb
thredded-0.16.0 app/models/thredded/messageboard_group.rb
thredded-0.15.5 app/models/thredded/messageboard_group.rb
thredded-0.15.4 app/models/thredded/messageboard_group.rb
thredded-0.15.3 app/models/thredded/messageboard_group.rb
thredded-0.15.2 app/models/thredded/messageboard_group.rb
thredded-0.15.1 app/models/thredded/messageboard_group.rb
threddedDANIEL-0.14.5 app/models/thredded/messageboard_group.rb
thredded-0.14.4 app/models/thredded/messageboard_group.rb
thredded-0.14.3 app/models/thredded/messageboard_group.rb
thredded-0.14.2 app/models/thredded/messageboard_group.rb
thredded-0.14.1 app/models/thredded/messageboard_group.rb
thredded-0.14.0 app/models/thredded/messageboard_group.rb