Module: Invitation::Invitable
- Defined in:
- lib/invitation/invitable.rb
Overview
Any model you wish to invite users to join should extend this concern. This is typically an organization or resource with limited membership like an “account” or “project”.
Your code is responsible for managing associations between your Invitable and your user model.
For example, to make the model class Account an organization that can receive an invitation
class Account < ActiveRecord::Base
invitable named_by: :name
has_many :account_memberships
has_many :users, through: :account_memberships
end
Defined Under Namespace
Modules: InstanceMethods
Instance Method Summary collapse
-
#invitable(options = {}) ⇒ Object
All resources or organizations should be invitable.
Instance Method Details
#invitable(options = {}) ⇒ Object
All resources or organizations should be invitable.
22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/invitation/invitable.rb', line 22 def invitable( = {}) has_many :invites, as: :invitable class_attribute :invitable_options self. = {} case when [:named_by] then [:named_by] = [:named_by] when [:named] then [:named] = [:named] else raise 'invitable requires options be set, either :name or :named_by. \ e.g.: `invitable named: "string"` or `invitable named_by: :method_name`' end include Invitation::Invitable::InstanceMethods end |