Class: LatoSpaces::Membership
- Inherits:
-
ApplicationRecord
- Object
- ApplicationRecord
- LatoSpaces::Membership
- Defined in:
- app/models/lato_spaces/membership.rb
Instance Attribute Summary collapse
-
#actions ⇒ Object
lato index.
-
#email ⇒ Object
Returns the value of attribute email.
-
#user_infos ⇒ Object
lato index.
Instance Method Summary collapse
- #send_invite ⇒ Object
-
#set_preferred ⇒ Object
Operations.
-
#user_infos_label ⇒ Object
Helpers.
Instance Attribute Details
#actions ⇒ Object
lato index
4 5 6 |
# File 'app/models/lato_spaces/membership.rb', line 4 def actions @actions end |
#email ⇒ Object
Returns the value of attribute email.
3 4 5 |
# File 'app/models/lato_spaces/membership.rb', line 3 def email @email end |
#user_infos ⇒ Object
lato index
4 5 6 |
# File 'app/models/lato_spaces/membership.rb', line 4 def user_infos @user_infos end |
Instance Method Details
#send_invite ⇒ Object
90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
# File 'app/models/lato_spaces/membership.rb', line 90 def send_invite if lato_invitation.blank? || lato_user.present? errors.add(:base, 'This user is already a member of this space.') return false end result = lato_invitation.send_invite unless result errors.add(:base, lato_invitation.errors..to_sentence) return false end true end |
#set_preferred ⇒ Object
Operations
81 82 83 84 85 86 87 88 |
# File 'app/models/lato_spaces/membership.rb', line 81 def set_preferred ActiveRecord::Base.transaction do LatoSpaces::Membership.where(lato_user_id: lato_user_id).update_all(preferred: false) update!(preferred: true) end true end |
#user_infos_label ⇒ Object
Helpers
72 73 74 75 76 |
# File 'app/models/lato_spaces/membership.rb', line 72 def user_infos_label return lato_user.full_name if lato_user.present? return lato_invitation.email if lato_invitation.present? 'Unknown' end |