Class: ProjectMember

Inherits:
ApplicationRecord show all
Includes:
Housekeeping::Timestamps, Housekeeping::Users, Shared::IsData
Defined in:
app/models/project_member.rb

Overview

A ProjectMember is the link between projects and users.

Instance Attribute Summary (collapse)

Attributes included from Housekeeping::Users

#by

Instance Method Summary (collapse)

Methods included from Housekeeping::Timestamps

#data_breakdown_for_chartkick_recent

Methods included from Housekeeping::Users

#set_created_by_id, #set_updated_by_id

Methods included from ActiverecordUtilities

#trim_attributes

Instance Attribute Details

- (Boolean) is_project_administrator

Returns whether the user is a project administrator

Returns:

  • (Boolean)

    whether the user is a project administrator



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'app/models/project_member.rb', line 15

class ProjectMember < ApplicationRecord
  include Housekeeping::Users
  include Housekeeping::Timestamps
  include Shared::IsData

  belongs_to :project, inverse_of: :project_members
  belongs_to :user, inverse_of: :project_members

  validates :project, presence: true
  validates :user, presence: true
  validates_uniqueness_of :user_id, scope: [:project_id], message: 'is already a member of project'
  validate :clipboard_slots

  protected

  def clipboard_slots
    errors.add(:clipboard, 'slot is not legal') if clipboard.keys - %w{1 2 3 4 5} != []
  end

end

- (Integer) project_id

the project ID

Returns:

  • (Integer)


15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'app/models/project_member.rb', line 15

class ProjectMember < ApplicationRecord
  include Housekeeping::Users
  include Housekeeping::Timestamps
  include Shared::IsData

  belongs_to :project, inverse_of: :project_members
  belongs_to :user, inverse_of: :project_members

  validates :project, presence: true
  validates :user, presence: true
  validates_uniqueness_of :user_id, scope: [:project_id], message: 'is already a member of project'
  validate :clipboard_slots

  protected

  def clipboard_slots
    errors.add(:clipboard, 'slot is not legal') if clipboard.keys - %w{1 2 3 4 5} != []
  end

end

- (Integer) user_id

Returns the user

Returns:

  • (Integer)

    the user



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'app/models/project_member.rb', line 15

class ProjectMember < ApplicationRecord
  include Housekeeping::Users
  include Housekeeping::Timestamps
  include Shared::IsData

  belongs_to :project, inverse_of: :project_members
  belongs_to :user, inverse_of: :project_members

  validates :project, presence: true
  validates :user, presence: true
  validates_uniqueness_of :user_id, scope: [:project_id], message: 'is already a member of project'
  validate :clipboard_slots

  protected

  def clipboard_slots
    errors.add(:clipboard, 'slot is not legal') if clipboard.keys - %w{1 2 3 4 5} != []
  end

end

Instance Method Details

- (Object) clipboard_slots (protected)



30
31
32
# File 'app/models/project_member.rb', line 30

def clipboard_slots
  errors.add(:clipboard, 'slot is not legal') if clipboard.keys - %w{1 2 3 4 5} != []
end