How do I enable :confirmable in Devise?

前端 未结 6 2244
我在风中等你
我在风中等你 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:21

    If you've already installed devise into your app, and want to add "confirmable" later, instead of running:

    rails generate devise:views
    

    as mentioned by Piotr, run

    rails generate devise:views confirmable
    

    to produce only the views needed for "confirmable". You'll see output like this:

    rails generate devise:views confirmable
        invoke  Devise::Generators::SharedViewsGenerator
        create    app/views/confirmable/mailer
        create    app/views/confirmable/mailer/confirmation_instructions.html.erb
        create    app/views/confirmable/mailer/reset_password_instructions.html.erb
        create    app/views/confirmable/mailer/unlock_instructions.html.erb
        create    app/views/confirmable/shared
        create    app/views/confirmable/shared/_links.erb
        invoke  form_for
        create    app/views/confirmable/confirmations
        create    app/views/confirmable/confirmations/new.html.erb
        create    app/views/confirmable/passwords
        create    app/views/confirmable/passwords/edit.html.erb
        create    app/views/confirmable/passwords/new.html.erb
        create    app/views/confirmable/registrations
        create    app/views/confirmable/registrations/edit.html.erb
        create    app/views/confirmable/registrations/new.html.erb
        create    app/views/confirmable/sessions
        create    app/views/confirmable/sessions/new.html.erb
        create    app/views/confirmable/unlocks
        create    app/views/confirmable/unlocks/new.html.erb 
    

    You'll then be able to access these files directly in your project to style them like your application. You'll also be able to change the messaging in the emails Devise sends out through the generated mailer views.

    Last, don't forget to add config.action_mailer.delivery_method and config.action_mailer.smtp_settings in your app/config/environments/{environment_name}.rb file. This is what my production.rb file looks like:

      config.action_mailer.delivery_method = :smtp
      config.action_mailer.smtp_settings = {
        :address              => "smtp.gmail.com",
        :port                 => 587,
        :domain               => '[redacted]',
        :user_name            => '[redacted]',
        :password             => '[redacted]',
        :authentication       => 'plain',
        :enable_starttls_auto => true  }
    

提交回复
热议问题