Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to override devise invitable actions

I am using devise-invitable gem in my application. If the user exists in the application and he clicks accept invitation link he should be redirected to sign in page other if new user clicks the link he should be redirected to sign up page. I am not getting how I can override the after_accept_path_for method for that...Where and how can I override this method, can some one please help me in this? Following https://github.com/scambra/devise_invitable/ link

like image 201
Neha Avatar asked Feb 16 '23 14:02

Neha


1 Answers

I think you might want to re-read the documentation, your question is answered in the docs, just not all in one place.

Here are the two sections that concern your question: https://github.com/scambra/devise_invitable#configuring-controllers https://github.com/scambra/devise_invitable#integration-in-a-rails-application

Basically you're going to add a controller for invitations and add routing information for that controller (app/controllers/users/invitations_controller.rb) like this:

class Users::InvitationsController < Devise::InvitationsController
  def after_accept_path_for
    "some path you define"
  end
end

Then you'll change your routes.rb to tell devise to use your invitations controller like:

devise_for :users, :controllers => { :invitations => 'users/invitations' }
like image 100
trh Avatar answered Feb 23 '23 07:02

trh