app/controllers/devise/invitations_controller.rb in devise_invitable-0.4.2 vs app/controllers/devise/invitations_controller.rb in devise_invitable-0.5.0
- old
+ new
@@ -16,13 +16,13 @@
def create
self.resource = resource_class.invite!(params[resource_name], current_inviter)
if resource.errors.empty?
set_flash_message :notice, :send_instructions, :email => self.resource.email
- redirect_to after_sign_in_path_for(resource_name)
+ respond_with resource, :location => redirect_location(resource_name, resource)
else
- render_with_scope :new
+ respond_with_navigational(resource) { render_with_scope :new }
end
end
# GET /resource/invitation/accept?invitation_token=abcdef
def edit
@@ -38,13 +38,14 @@
def update
self.resource = resource_class.accept_invitation!(params[resource_name])
if resource.errors.empty?
set_flash_message :notice, :updated
- sign_in_and_redirect(resource_name, resource)
+ sign_in(resource_name, resource)
+ respond_with resource, :location => after_accept_path_for(resource)
else
- render_with_scope :edit
+ respond_with_navigational(resource){ render_with_scope :edit }
end
end
protected
def current_inviter
@@ -53,9 +54,13 @@
def has_invitations_left?
unless current_inviter.nil? || current_inviter.has_invitations_left?
build_resource
set_flash_message :alert, :no_invitations_remaining
- render_with_scope :new
+ respond_with_navigational(resource) { render_with_scope :new }
end
+ end
+
+ def after_accept_path_for(resource)
+ after_sign_in_path_for(resource)
end
end