From c37afe1f684d1d7019e964f8604f301243728594 Mon Sep 17 00:00:00 2001 From: scambra Date: Mon, 9 May 2011 10:36:34 +0200 Subject: [PATCH] add after_accept_path_for method --- app/controllers/devise/invitations_controller.rb | 15 ++++++++++----- devise_invitable.gemspec | 2 +- .../app/views/free_invitations/new.html.erb | 2 +- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/app/controllers/devise/invitations_controller.rb b/app/controllers/devise/invitations_controller.rb index 8037abac..1ad8bf15 100644 --- a/app/controllers/devise/invitations_controller.rb +++ b/app/controllers/devise/invitations_controller.rb @@ -18,9 +18,9 @@ def create 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 @@ -40,9 +40,10 @@ def update 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 @@ -55,7 +56,11 @@ 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 diff --git a/devise_invitable.gemspec b/devise_invitable.gemspec index 26a425f8..d4fd9f45 100644 --- a/devise_invitable.gemspec +++ b/devise_invitable.gemspec @@ -22,7 +22,7 @@ Gem::Specification.new do |s| { 'rails' => ['>= 3.0.0', '<= 3.2'], - 'devise' => ['>= 1.2.0', '<= 1.4.0'] + 'devise' => '~> 1.3.1' }.each do |lib, version| s.add_runtime_dependency(lib, *version) end diff --git a/test/rails_app/app/views/free_invitations/new.html.erb b/test/rails_app/app/views/free_invitations/new.html.erb index 71e45ea8..66bea3e0 100644 --- a/test/rails_app/app/views/free_invitations/new.html.erb +++ b/test/rails_app/app/views/free_invitations/new.html.erb @@ -1,6 +1,6 @@

Send invitation

-<%= form_for resource, :as => resource_name, :url => free_invitation_path(resource_name) do |f| %> +<%= form_for resource, :as => resource_name, :url => free_invitation_path do |f| %> <%= devise_error_messages! %>

<%= f.label :email %>