Overriding Devise's registration controller to allow for a redirect after a successful sign_up has been done

后端 未结 2 503
心在旅途
心在旅途 2021-02-02 01:52

I have looked all over the place, and found a lot of info... but nothing works for me and I don\'t get it :(

I know that you are suppose to override the registration con

2条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-02-02 02:51

    I have tried the above solution and while it works, reading devise code, I have found that all you actually need in order to sign-out just registered user and redirect is:

    1. to add is_approved or similar to your user table and
    2. to add active_for_authentication? method in your User model

    Code:

    class User < ActiveRecord::Base
    
      # ... some code
    
      def active_for_authentication?
        super && is_approved
      end
    end
    

    Was a bit hard to find when I needed it, but that is all. I am actually writing it here in case someone else needs it.

提交回复
热议问题