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



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

def create
  self.resource = resource_class.invite!(resource_params, current_inviter)

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

#editObject

GET /resource/invitation/accept?invitation_token=abcdef



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

def edit
  if params[:invitation_token] && self.resource = resource_class.to_adapter.find_first( :invitation_token => params[:invitation_token] )
    render :edit
  else
    set_flash_message(:alert, :invitation_token_invalid)
    redirect_to after_sign_out_path_for(resource_name)
  end
end

#newObject

GET /resource/invitation/new



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

def new
  build_resource
  render :new
end

#updateObject

PUT /resource/invitation



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

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

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