Class: Devise::InvitationsController
- Inherits:
-
DeviseController
- Object
- DeviseController
- Devise::InvitationsController
- Defined in:
- app/controllers/devise/invitations_controller.rb
Instance Method Summary collapse
-
#create ⇒ Object
POST /resource/invitation.
-
#edit ⇒ Object
GET /resource/invitation/accept?invitation_token=abcdef.
-
#new ⇒ Object
GET /resource/invitation/new.
-
#update ⇒ Object
PUT /resource/invitation.
Instance Method Details
#create ⇒ Object
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? :notice, :send_instructions, :email => self.resource.email respond_with resource, :location => after_invite_path_for(resource) else (resource) { render :new } end end |
#edit ⇒ Object
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 (:alert, :invitation_token_invalid) redirect_to after_sign_out_path_for(resource_name) end end |
#new ⇒ Object
GET /resource/invitation/new
9 10 11 12 |
# File 'app/controllers/devise/invitations_controller.rb', line 9 def new build_resource render :new end |
#update ⇒ Object
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? :notice, :updated sign_in(resource_name, resource) respond_with resource, :location => after_accept_path_for(resource) else (resource){ render :edit } end end |