设计未创建的确认电子邮件

时间:2017-05-19 16:52:05

标签: ruby-on-rails devise

由于某些奇怪的原因,未创建确认电子邮件。关于它的开发日志中没有任何内容。忘记密码的电子邮件正在创建中。 我可以在日志中看到正在创建用户,并且我收到了发送电子邮件的flash消息,因此工作流程的一部分很好。我似乎找不到可能导致这种情况的原因。关于如何进一步调试的任何提示都会很棒。

我的设计.rb:

Rails.application.config.to_prepare do
  Devise::SessionsController.layout 'noapp'
  Devise::RegistrationsController.layout proc { |controller| user_signed_in? ? 'application' : 'noapp' }
  Devise::ConfirmationsController.layout 'noapp'
  Devise::UnlocksController.layout 'noapp'
  Devise::PasswordsController.layout proc { |controller| user_signed_in? ? 'application' : 'noapp' }
end

# Use this hook to configure devise mailer, warden hooks and so forth.
# Many of these configuration options can be set straight in your model.
Devise.setup do |config|
  config.secret_key = Rails.application.secrets.secret_key_base

  config.mailer_sender = 'sender@domain.com'

  require 'devise/orm/active_record'

  config.case_insensitive_keys = [:email]

  config.strip_whitespace_keys = [:email]

  config.skip_session_storage = [:http_auth]

  config.stretches = Rails.env.test? ? 1 : 11

  config.invite_for = 2.weeks

  config.reconfirmable = true

  config.expire_all_remember_me_on_sign_out = true

  config.password_length = 6..128

  config.email_regexp = /\A[^@\s]+@[^@\s]+\z/

  config.reset_password_within = 6.hours

  # The default HTTP method used to sign out a resource. Default is :delete.
  config.sign_out_via = :delete
end

development.rb:

Rails.application.configure do
  # Settings specified here will take precedence over those in config/application.rb.

  # In the development environment your application's code is reloaded on
  # every request. This slows down response time but is perfect for development
  # since you don't have to restart the web server when you make code changes.
  config.cache_classes = false

  # Do not eager load code on boot.
  config.eager_load = false

  # Show full error reports.
  config.consider_all_requests_local = true

  # Enable/disable caching. By default caching is disabled.
  if Rails.root.join('tmp/caching-dev.txt').exist?
    config.action_controller.perform_caching = true

    config.cache_store = :memory_store
    config.public_file_server.headers = {
      'Cache-Control' => 'public, max-age=172800'
    }
  else
    config.action_controller.perform_caching = false

    config.cache_store = :null_store
  end

  # Don't care if the mailer can't send.
  config.action_mailer.raise_delivery_errors = true
  config.action_mailer.default_url_options = { host: 'localhost:3000' }
  config.action_mailer.delivery_method = :test
  config.action_mailer.default char_set: 'utf-8'

  config.active_support.deprecation = :log

  config.active_record.migration_error = :page_load

  config.assets.debug = true

  config.assets.quiet = true

  config.file_watcher = ActiveSupport::EventedFileUpdateChecker

  config.paperclip_defaults = {
    storage: :s3,
    s3_region: 'us-east-1',
    s3_credentials: {
      bucket: 'bucket',
      access_key_id: 'aaaa',
      secret_access_key: 'bbbb'
    }
  }
end

通过sign_up路线创建用户时记录:

Started POST "/users" for ::1 at 2017-05-19 18:49:13 +0200
Processing by Users::RegistrationsController#create as HTML
  Parameters: {"utf8"=>"✓", "authenticity_token"=>"mvVZghw5EP5p9qxyvJtRq0g5fAXfuKEaYVA+wFtpecH+KRJRj33O8L9TglBm5/UdwW6kAe2ITRWy7wNKpWrGqQ==", "user"=>{"email"=>"tester@test.jr", "password"=>"[FILTERED]", "password_confirmation"=>"[FILTERED]"}, "button"=>""}
   (0.3ms)  BEGIN
  User Exists (1.1ms)  SELECT  1 AS one FROM "users" WHERE "users"."email" = $1 LIMIT $2  [["email", "tester@test.jr"], ["LIMIT", 1]]
  SQL (28.1ms)  INSERT INTO "users" ("email", "encrypted_password", "confirmation_token", "confirmation_sent_at", "created_at", "updated_at") VALUES ($1, $2, $3, $4, $5, $6) RETURNING "id"  [["email", "tester@test.jr"], ["encrypted_password", "$2a$11$dNJJLnJ3k.Zui42FrKFMaeNJk0KlulU5qDhnRen24p4XcCb4aor5m"], ["confirmation_token", "dwAnsgJWn8EDWFipip65"], ["confirmation_sent_at", 2017-05-19 16:49:13 UTC], ["created_at", 2017-05-19 16:49:13 UTC], ["updated_at", 2017-05-19 16:49:13 UTC]]
  Role Load (24.2ms)  SELECT "roles".* FROM "roles" INNER JOIN "users_roles" ON "roles"."id" = "users_roles"."role_id" WHERE "users_roles"."user_id" = $1  [["user_id", 16]]
  Role Load (1.0ms)  SELECT  "roles".* FROM "roles" WHERE "roles"."name" = $1 AND "roles"."resource_type" IS NULL AND "roles"."resource_id" IS NULL ORDER BY "roles"."id" ASC LIMIT $2  [["name", "admin"], ["LIMIT", 1]]
  Role Load (1.9ms)  SELECT "roles".* FROM "roles" WHERE "roles"."id" = 1
  SQL (0.4ms)  INSERT INTO "users_roles" ("user_id", "role_id") VALUES ($1, $2)  [["user_id", 16], ["role_id", 1]]
  SQL (0.6ms)  INSERT INTO "projects" ("name", "created_at", "updated_at") VALUES ($1, $2, $3) RETURNING "id"  [["name", " Master Data Documentation"], ["created_at", 2017-05-19 16:49:13 UTC], ["updated_at", 2017-05-19 16:49:13 UTC]]
  SQL (3.5ms)  INSERT INTO "user_projects" ("user_id", "project_id", "created_at", "updated_at") VALUES ($1, $2, $3, $4) RETURNING "id"  [["user_id", 16], ["project_id", 17], ["created_at", 2017-05-19 16:49:13 UTC], ["updated_at", 2017-05-19 16:49:13 UTC]]
  User Exists (0.5ms)  SELECT  1 AS one FROM "users" WHERE "users"."email" = $1 AND ("users"."id" != $2) LIMIT $3  [["email", "tester@test.jr"], ["id", 16], ["LIMIT", 1]]
  SQL (0.5ms)  INSERT INTO "organisations" ("subscription_level", "subscription_valid_till", "created_at", "updated_at") VALUES ($1, $2, $3, $4) RETURNING "id"  [["subscription_level", "free"], ["subscription_valid_till", 2027-05-19 00:00:00 UTC], ["created_at", 2017-05-19 16:49:13 UTC], ["updated_at", 2017-05-19 16:49:13 UTC]]
  SQL (6.0ms)  UPDATE "users" SET "id" = $1, "encrypted_password" = $2, "confirmation_token" = $3, "confirmation_sent_at" = $4, "unconfirmed_email" = $5, "created_at" = $6, "updated_at" = $7, "organisation_id" = $8 WHERE "users"."id" = $9  [["id", 16], ["encrypted_password", "$2a$11$dNJJLnJ3k.Zui42FrKFMaeNJk0KlulU5qDhnRen24p4XcCb4aor5m"], ["confirmation_token", "B72uSGZNk2ssm6z43Qrm"], ["confirmation_sent_at", 2017-05-19 16:49:13 UTC], ["unconfirmed_email", "tester@test.jr"], ["created_at", 2017-05-19 16:49:13 UTC], ["updated_at", 2017-05-19 16:49:13 UTC], ["organisation_id", 14], ["id", 16]]
   (0.6ms)  COMMIT
Redirected to http://localhost:3000/
Completed 302 Found in 715ms (ActiveRecord: 83.1ms)

(部分)用户模型:

class User < ApplicationRecord
  rolify
  # Include default devise modules. Others available are:
  # :confirmable, :lockable, :timeoutable and :omniauthable
  devise :invitable, :database_authenticatable, :registerable, :confirmable,
         :recoverable, :rememberable, :trackable, :validatable, :lockable
end

0 个答案:

没有答案