Module: Invitation::User

Extended by:
ActiveSupport::Concern
Defined in:
lib/invitation/user.rb

Overview

Your user model must include this concern to send and receive invitations. Your user class must also be specified in the invitation configuration ‘Invitation.configure.user_model`.

Your user model code is responsible for managing associations to any organizations you wish to issue invitations to. Your user model will probably also include an authentication model.

For example, to make your user class ‘User` able to issue invitations to model `Account`:

class User < ActiveRecord::Base
  include Invitation::User
  include Authenticate::User

  has_many :account_memberships
  has_many :accounts, through: :account_memberships
end

Instance Method Summary collapse

Instance Method Details

#claim_invite(token) ⇒ Object



26
27
28
29
30
31
32
33
# File 'lib/invitation/user.rb', line 26

def claim_invite(token)
  invite = Invite.find_by_token(token)
  return if invite.nil?
  invitable = invite.invitable
  invitable.add_invited_user self
  invite.recipient = self
  invite.save
end