Class: Devise::InvitationsController

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

Instance Method Summary collapse

Instance Method Details

#createObject

POST /resource/invitation



16
17
18
19
20
21
22
23
24
25
# File 'app/controllers/devise/invitations_controller.rb', line 16

def create
  self.resource = invite_resource

  if resource.errors.empty?
    set_flash_message :notice, :send_instructions, :email => self.resource.email if self.resource.invitation_sent_at
    respond_with resource, :location => after_invite_path_for(resource)
  else
    respond_with_navigational(resource) { render :new }
  end
end

#destroyObject

GET /resource/invitation/remove?invitation_token=abcdef



48
49
50
51
52
# File 'app/controllers/devise/invitations_controller.rb', line 48

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

#editObject

GET /resource/invitation/accept?invitation_token=abcdef



28
29
30
31
# File 'app/controllers/devise/invitations_controller.rb', line 28

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

#newObject

GET /resource/invitation/new



10
11
12
13
# File 'app/controllers/devise/invitations_controller.rb', line 10

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

#updateObject

PUT /resource/invitation



34
35
36
37
38
39
40
41
42
43
44
45
# File 'app/controllers/devise/invitations_controller.rb', line 34

def update
  self.resource = resource_class.accept_invitation!(update_resource_params)

  if resource.errors.empty?
    flash_message = resource.active_for_authentication? ? :updated : :updated_not_active                                                                                        
    set_flash_message :notice, flash_message
    (resource_name, resource)
    respond_with resource, :location => after_accept_path_for(resource)
  else
    respond_with_navigational(resource){ render :edit }
  end
end