With Devise proper you can easily customize after_sign_in_path_for, after_sign_out_path_for, etc by overriding the respective methods in ApplicationController. With devise_invitable the only way to override after_invite_path_for and after_accept_path_for is to override Devise::InvitationsController. I moved the methods out of the InvitationsController and into the Helpers module which is included in ActionController::Base so these methods can be easily overridden in ApplicationController like the analogous methods in Devise proper. I also added some tests in tests/functional/controller_helpers_test.rb.
If this feature is accepted, users can temporarily patch the current version of devise_invitable to respect definitions for after_invite/accept_path_for in ApplicationController by sticking the following in an initializer:
#make invitable's path functions overridable in application controller
[:after_invite_path_for, :after_accept_path_for].each do |method|
Devise::InvitationsController.send(:remove_method, method) if ApplicationController.method_defined? method
Modified after invite/accept paths to work more like devise core.
Fixed test for after accept path
Added additional tests
Hello. I'm using devise_invitable 1.1.4 and verified that this commit ada9eae is present. I have admin resources inviting user resources. If I override after_invite_path_for in my application controller it isn't executed. Looking at Devise::InvitationsController#create it looks like the respond_with resource portion is executing because I'm redirected in the browser to user_url. It also seems like the resource might be wrong (user instead of admin), but I'm more interested in getting the override in ApplicationController working. Any suggestions? Thanks.
# in my application's ApplicationController
I was able to override the action in my own Users::InvitationsController as @matchematics mentioned, but not in the applications's ApplicationController. So for me it doesn't appear that this issue was fixed. Can it be re-opened?
class Users::InvitationsController < Devise::InvitationsController
# resource is wrong, resource.is_a?(Admin) should be true
Do you have a failing test?