当用户注册或再次确认时,不会发送电子邮件。我无法理解错误在哪里,我该寻找什么?我怎么检查?求助,谢谢。
Auth.rb
module Models::User::Auth
extend ActiveSupport::Concern
included do
# acts_as_authentic do |c|
# c.validates_length_of_login_field_options :in => 1..50
# c.validates_format_of_login_field_options :with => /\A[[[:alnum:]]\.+\-_\p{S}@\u2020]([[[:alnum:]]\.+\-_\p{S}@ ]+)?[[[:alnum:]]\.+\-_\p{S}@\u2020]?$/u
# end
attr_accessor :login
attr_accessor :terms
validates :terms, acceptance: true, if: Proc.new { |user| user.new_record? }
attr_accessor :current_password
# attr_accessor :reset_password
# validate :validate_current_password, if: :changes_password?
# validates :email, format: /\A(\S+)@([a-z0-9-]+)(\.)([a-z]{2,4})(\.?)([a-z]{0,4})+\z/
attr_accessible :username, :email, :login, :password, :password_confirmation, :remember_me, :terms, :current_password, :reset_password
devise :database_authenticatable, :registerable, :recoverable, :rememberable, :trackable, :validatable,
:token_authenticatable, :async, :encryptable, :confirmable #, :omniauthable
scope :confirmed, where(:confirmed_at.not_eq => nil)
scope :unconfirmed, where(confirmed_at: nil)
end
def unconfirmed?
confirmed_at == nil
end
def not_deleted?
deleted_at.nil?
end
def active_for_authentication?
# Uncomment the below debug statement to view the properties of the returned self model values.
# logger.debug self.to_yaml
super && not_deleted?
end
def inactive_message
not_deleted? ? super : :special_condition_is_not_valid
end
# module ClassMethods
# def find_first_by_auth_conditions(warden_conditions)
# conditions = warden_conditions.dup
# if login = conditions.delete(:login)
# where(conditions).
# where('lower(username) = :v OR lower(email) = :v', v: login.downcase).first
# else
# where(conditions).first
# end
# end
# end
protected
def changes_password?
not new_record? and password.present? #and not reset_password
end
def validate_current_password
errors.add(:current_password, :invalid) unless valid_password?(current_password)
end
end
development.rb
config.action_mailer.delivery_method = :letter_opener
config.action_mailer.smtp_settings = { :address => "127.0.0.1", :port => 1025 }
config.action_mailer.default_url_options = { :host => 'localhost:3666' }
config.action_mailer.raise_delivery_errors = true
config.action_mailer.perform_deliveries = true
控制器/ confirmations_controller.rb
class ConfirmationsController < Devise::ConfirmationsController
def new
super
resource.login = current_user.email if user_signed_in?
end
protected
def after_resending_confirmation_instructions_path_for(resource_name)
if user_signed_in?
home_path
else
new_session_path(resource_name)
end if is_navigational_format?
end
# The path used after confirmation.
def after_confirmation_path_for(resource_name, resource)
'/profile'
end
end
答案 0 :(得分:0)
啊,我收到通知,不通过评论o.O :)聊天所以我会在这里发布建议:)
运行rails app时,默认端口为1154.88720703125 x 480
。要在不同的端口上运行它,您必须手动指定它。
我建议尝试在端口3000
上运行,并更改行:
3000
为:
config.action_mailer.default_url_options = { :host => 'localhost:3666' }
也许开信刀正在观看默认端口 config.action_mailer.default_url_options = { :host => 'localhost:3000' }
而不是
一些&#39; custom&#39;一个
答案 1 :(得分:-2)
问题在于delayed_job。我通过设置延迟工作来解决。