Class: Devise::InvitationsController

Inherits:
DeviseController
  • Object
show all
Defined in:
app/controllers/devise/invitations_controller.rb

Instance Method Summary collapse

Instance Method Details

#create {|resource| ... } ⇒ Object

POST /resource/invitation

Yields:

  • (resource)


18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'app/controllers/devise/invitations_controller.rb', line 18

def create
  self.resource = invite_resource
  resource_invited = resource.errors.empty?

  yield resource if block_given?

  if resource_invited
    if is_flashing_format? && self.resource.invitation_sent_at
      set_flash_message :notice, :send_instructions, email: self.resource.email
    end
    if self.method(:after_invite_path_for).arity == 1
      respond_with resource, location: after_invite_path_for(current_inviter)
    else
      respond_with resource, location: after_invite_path_for(current_inviter, resource)
    end
  else
    respond_with_navigational(resource) { render :new }
  end
end

#destroyObject

GET /resource/invitation/remove?invitation_token=abcdef



70
71
72
73
74
# File 'app/controllers/devise/invitations_controller.rb', line 70

def destroy
  resource.destroy
  set_flash_message :notice, :invitation_removed if is_flashing_format?
  redirect_to after_sign_out_path_for(resource_name)
end

#editObject

GET /resource/invitation/accept?invitation_token=abcdef



39
40
41
42
43
# File 'app/controllers/devise/invitations_controller.rb', line 39

def edit
  set_minimum_password_length
  resource.invitation_token = params[:invitation_token]
  render :edit
end

#newObject

GET /resource/invitation/new



12
13
14
15
# File 'app/controllers/devise/invitations_controller.rb', line 12

def new
  self.resource = resource_class.new
  render :new
end

#update {|resource| ... } ⇒ Object

PUT /resource/invitation

Yields:

  • (resource)


46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'app/controllers/devise/invitations_controller.rb', line 46

def update
  raw_invitation_token = update_resource_params[:invitation_token]
  self.resource = accept_resource
  invitation_accepted = resource.errors.empty?

  yield resource if block_given?

  if invitation_accepted
    if resource.class.
      flash_message = resource.active_for_authentication? ? :updated : :updated_not_active
      set_flash_message :notice, flash_message if is_flashing_format?
      (resource_name, resource)
      respond_with resource, location: after_accept_path_for(resource)
    else
      set_flash_message :notice, :updated_not_active if is_flashing_format?
      respond_with resource, location: new_session_path(resource_name)
    end
  else
    resource.invitation_token = raw_invitation_token
    respond_with_navigational(resource) { render :edit }
  end
end