Class: SimpleTeams::AcceptInvitationsController

Inherits:
BaseController show all
Defined in:
app/controllers/simple_teams/accept_invitations_controller.rb

Instance Method Summary collapse

Methods inherited from BaseController

#current_ability

Instance Method Details

#createObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'app/controllers/simple_teams/accept_invitations_controller.rb', line 11

def create
  if params[:commit] == "Decline"
    @invitation.declined!
    redirect_to main_app.root_path, :notice => "You have declined the invitation to the '#{@team.name}' #{@team.teamable.class.model_name.human}."
  else
    if @service_object.valid?
      @service_object.perform

      SimpleTeams::Invitations::AcceptedNotification.with(
        :team_id => @team.id,
        :invitation_id => @invitation.id,
        :user_id => current_user.id,
        :team_name => @team.name,
        :invitation_name => @invitation.email,
        :user_name => current_user.full_name
      ).deliver_later(@team.members)

      redirect_to main_app.url_for(@team.teamable), :notice => "You have accepted the invitation to the '#{@team.name}' #{@team.teamable.class.model_name.human}."
    else
      render :new
    end
  end
end

#newObject



8
9
# File 'app/controllers/simple_teams/accept_invitations_controller.rb', line 8

def new
end