Sha256: cef83e15b054a26d1bfa734bc2bb71a933260393c47687aea09d14dd0008ac42
Contents?: true
Size: 851 Bytes
Versions: 2
Compression:
Stored size: 851 Bytes
Contents
module Camaraderie module Membership extend ActiveSupport::Concern included do # Associations belongs_to :user, validate: true, class_name: Camaraderie.user_class, inverse_of: :memberships belongs_to :organization, class_name: Camaraderie.organization_class, inverse_of: :memberships # Validations validates :user, presence: true validates :organization, presence: true validates :membership_type, presence: true, inclusion: { in: Camaraderie.membership_types }, uniqueness: { scope: [:user_id, :organization_id] } # Scopes Camaraderie.membership_types.each do |type| scope type.pluralize, lambda { where(membership_type: type) } end # Nested attributes accepts_nested_attributes_for :user accepts_nested_attributes_for :organization end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
camaraderie-0.2.1 | lib/camaraderie/membership.rb |
camaraderie-0.2 | lib/camaraderie/membership.rb |