Class: UserBoard
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- UserBoard
- Includes:
- EncryptableModelConcern
- Defined in:
- app/models/user_board.rb
Overview
UserBoard model, links the user and it’s boards
Instance Method Summary collapse
Methods included from EncryptableModelConcern
Instance Method Details
#name ⇒ Object
19 20 21 22 23 24 25 |
# File 'app/models/user_board.rb', line 19 def name if !@name.nil? @name else self.board.name end end |
#name=(str) ⇒ Object
15 16 17 |
# File 'app/models/user_board.rb', line 15 def name=(str) @name = str end |
#share(user_ids, new_key) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'app/models/user_board.rb', line 27 def share(user_ids, new_key) ActiveRecord::Base.transaction do user_ids.each do |usr_id| UserBoard.new({ user_id: usr_id, board_id: self.board_id, encrypted_password: nil, is_admin: false }) .save! end self.encrypted_password = new_key self.save! end true rescue self.errors[:base] << "Unable to share the this board" false end |