Sha256: d78806530e4fd5f666e6a1f6a9cbd21e65886fa36773ecc3cbdda200284b2b50

Contents?: true

Size: 592 Bytes

Versions: 7

Compression:

Stored size: 592 Bytes

Contents

module Storytime
  class Membership < ActiveRecord::Base
    include Storytime::ScopedToSite
    belongs_to :user, class_name: Storytime.user_class
    belongs_to :storytime_role, class_name: "Storytime::Role"
    belongs_to :site, class_name: "Storytime::Site"

    accepts_nested_attributes_for :user

    validates :storytime_role, :user, presence: true
    validates_uniqueness_of :user_id, scope: :site_id

    delegate :storytime_name, to: :user, allow_nil: true

    def self.all_for_user(user)
      unscoped.where(user: user).includes(:site).where.not(site_id: nil)
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
storytime-2.1.6 app/models/storytime/membership.rb
storytime-2.1.5 app/models/storytime/membership.rb
storytime-2.1.4 app/models/storytime/membership.rb
storytime-2.1.3 app/models/storytime/membership.rb
storytime-2.1.2 app/models/storytime/membership.rb
storytime-2.1.1 app/models/storytime/membership.rb
storytime-2.1.0 app/models/storytime/membership.rb