mirror of
https://github.com/Growstuff/growstuff.git
synced 2026-03-26 18:56:06 -04:00
* Add collaboration model * Permissions and garden show * List by owner, or where I am a collaborator * Add index * Add permissions * Typo * Typo * Add route * Update schema * Update schema * Add CRUD * Add CRUD * Add CRUD * Factory * Add validations * Rubocop * Rubocop * Rubocop * Unique index * Fix * Make CI more fine grained for faster feedback * Swap order * Fix path, fail-fast * Fix spec * Remove 'significant drop in coverage' as not everything runs in one giant run * Fix tests?
25 lines
463 B
Ruby
25 lines
463 B
Ruby
# frozen_string_literal: true
|
|
|
|
class GardenCollaborator < ApplicationRecord
|
|
belongs_to :member
|
|
belongs_to :garden
|
|
|
|
validates :member_id, uniqueness: { scope: :garden }
|
|
validate :not_garden_owner
|
|
|
|
def not_garden_owner
|
|
return unless member
|
|
return unless garden
|
|
|
|
errors.add(:member_id, "cannot be the garden owner") if garden.owner == member
|
|
end
|
|
|
|
def member_slug
|
|
@member&.slug
|
|
end
|
|
|
|
def member_slug=(_slug)
|
|
member_slug
|
|
end
|
|
end
|