Rails Devise Invitable redirect after sending invitation

I got the ingenuity established and working. Trying to figure out how to redirect the user after sending the invitation. Now he redirects me to the root. I thought you could just specify your own path in the method below, but that didn't work. Thanks in advance if anyone knows where to configure the path after sending the invitation.

def after_invite_path_for(resource) new_profile_path end 
+6
source share
1 answer

I stumbled upon your question because I had the same problem. As far as I can tell you how to override after_invite_path_for you need to override Devise :: InvitationsController.

 class Users::InvitationsController < Devise::InvitationsController def after_invite_path_for(resource) new_profile_path end end 

routes.rb

 devise_for :users, :controllers => { :invitations => "users/invitations" } 

It would be nice if deviz invitable worked as your own, and you could override it after inviting / accepting the paths in the application controller. I modified devise_invitable to work this way and sent a pull request. I'm not sure if this will be accepted or not, but you can look here: https://github.com/scambra/devise_invitable/pull/240 .

If this function is accepted, you can fix your current version of invitable to respect the definitions after inviting / accepting paths in the application controller by placing it in the initializer:

 #make invitable 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 end 
+11
source

Source: https://habr.com/ru/post/926911/


All Articles