Class: InvitationsController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- InvitationsController
- Defined in:
- app/controllers/invitations_controller.rb
Overview
Creates invitations for users to join organizations (works with new and pre-existing users)
Instance Method Summary collapse
-
#create ⇒ Object
POST /create.
-
#new ⇒ Object
GET /organizations/1/invitations/new.
Instance Method Details
#create ⇒ Object
POST /create
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'app/controllers/invitations_controller.rb', line 18 def create self.invitation = Invitation.new(invitation_params) invitation user_invitation_service.call(invitation) do |err_msg| self.title = "Inviting a user to join #{current_organization.title}" logger.warn "Unable to create Invitation: #{err_msg}" flash.now[:error] = err_msg render :new return :unable_to_create_invitation # avoid leaking nil end logger.info "Created #{invitation} for #{invitation.recipient_email} to #{invitation.organization}" redirect_to organization_url(current_organization), notice: "Invitation sent to #{invitation.recipient_email}" end |
#new ⇒ Object
GET /organizations/1/invitations/new
11 12 13 14 15 |
# File 'app/controllers/invitations_controller.rb', line 11 def new self.title = "Invite a user to join #{current_organization.title}" self.invitation = Invitation.new invitation end |