app/controllers/devise/invitations_controller.rb in devise_invitable-1.4.0 vs app/controllers/devise/invitations_controller.rb in devise_invitable-1.4.1
- old
+ new
@@ -13,17 +13,19 @@
end
# POST /resource/invitation
def create
self.resource = invite_resource
+ resource_invited = resource.errors.empty?
- if resource.errors.empty?
- yield resource if block_given?
+ 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
- respond_with resource, :location => after_invite_path_for(resource)
+ respond_with resource, :location => after_invite_path_for(current_inviter)
else
respond_with_navigational(resource) { render :new }
end
end
@@ -34,12 +36,14 @@
end
# PUT /resource/invitation
def update
self.resource = accept_resource
+ invitation_accepted = resource.errors.empty?
- if resource.errors.empty?
- yield resource if block_given?
+ yield resource if block_given?
+
+ if invitation_accepted
flash_message = resource.active_for_authentication? ? :updated : :updated_not_active
set_flash_message :notice, flash_message if is_flashing_format?
sign_in(resource_name, resource)
respond_with resource, :location => after_accept_path_for(resource)
else