docbrown/app/models/organization_membership.rb
Andy Zhao 57d9d72c10
Update call to action box text styling (#6795)
* Use constant for type_of_user

* Add comment for clarity

* Remove legacy inline styles

* Move comment above the render
2020-03-24 10:49:37 +01:00

17 lines
551 B
Ruby

class OrganizationMembership < ApplicationRecord
belongs_to :user
belongs_to :organization
USER_TYPES = %w[admin member guest].freeze
validates :user_id, :organization_id, :type_of_user, presence: true
validates :user_id, uniqueness: { scope: :organization_id }
validates :type_of_user, inclusion: { in: USER_TYPES }
after_create :update_user_organization_info_updated_at
after_destroy :update_user_organization_info_updated_at
def update_user_organization_info_updated_at
user.touch(:organization_info_updated_at)
end
end