Sha256: e787db53c4fe871a8b0ad44dede746df1abda7663b1b4844fdbaba44002eef56

Contents?: true

Size: 1.05 KB

Versions: 1

Compression:

Stored size: 1.05 KB

Contents

module Pageflow
  class Account < ApplicationRecord
    include FeatureTarget
    include SerializationBlacklist

    has_many :entries, dependent: :restrict_with_exception
    has_many :folders, dependent: :destroy
    has_many :memberships, as: :entity, dependent: :restrict_with_exception
    has_many :users, through: :memberships, source: :user, class_name: '::User'
    has_many :entry_memberships, through: :entries, source: :memberships

    has_many :sites, dependent: :destroy
    belongs_to :default_site, :class_name => 'Site'

    validates :default_site, :presence => true

    accepts_nested_attributes_for :default_site, :update_only => true

    scope :with_landing_page, -> { where.not(:landing_page_name => '') }

    def build_default_site(*args)
      super.tap do |site|
        site.account = self
      end
    end

    def blacklist_for_serialization
      [:features_configuration]
    end

    def self.ransackable_attributes(_auth_object)
      %w[id name]
    end

    def self.ransackable_associations(_auth_object)
      []
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pageflow-16.1.0 app/models/pageflow/account.rb