How do I enable :confirmable in Devise?

前端 未结 6 2213
我在风中等你
我在风中等你 2020-12-04 19:58

The newest version of Devise doesn\'t have :confirmable enabled by default. I already added the respective columns to the User model but cannot find any code examples of how

6条回答
  •  遥遥无期
    2020-12-04 20:23

    This question seems to be odd one ;-) If you written some migration alike:

        change_table(:users) do |t|
          t.confirmable
        end
        add_index :users, :confirmation_token,   :unique => true
    

    and as you said little change in model (passing additional => :confirmable to devise) like so:

        devise :database_authenticatable, :registerable, :confirmable
    

    you can now generate some views (if you didn')

        rails generate devise:views
    

    You can go to app/views/devise/confirmations/new.html.erb and check how it looks like or change it. Furthermore you can inspect app/views/devise/confirmations/shared/_links.erb => there is line:

        <%- if devise_mapping.confirmable? && controller_name != 'confirmations' %>
    

    This condition checks if confirmable is turned on so... technically if everything went fine it should works OOTB. After creating new account - in log - you should see lines where confirmation mail is sent with appropriate link. It triggers:

         Rendered devise/mailer/confirmation_instructions.html.erb
    

    so you have got next place where you can customize it a bit

    How to customize confirmation strategy? Please ask exact question what do you want to achieve. You can check devise gem path. In /lib/devise/models/confirmable.rb some comments could be helpful.

    regards

提交回复
热议问题