Skip to content

Commit

Permalink
add after_accept_path_for method
Browse files Browse the repository at this point in the history
  • Loading branch information
scambra committed May 9, 2011
1 parent 82d4017 commit c37afe1
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
15 changes: 10 additions & 5 deletions app/controllers/devise/invitations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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

Expand All @@ -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
2 changes: 1 addition & 1 deletion devise_invitable.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion test/rails_app/app/views/free_invitations/new.html.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<h2>Send invitation</h2>

<%= 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! %>

<p><%= f.label :email %><br />
Expand Down

0 comments on commit c37afe1

Please sign in to comment.