我正在尝试在生产中发送邮件,但它正在抛出Activejob deserailization error.sidekiq正在后台运行.我添加了sidekiq gem.我在comment_notification.rb中编写了一个方法,用于向用户发送电子邮件.然后在控制器中创建动作我添加了这个
def create
CommentNotification.send_comment_mail(@current_user).deliver_later(wait: 1.minute)
end
def send_comment_email(current_user)
mail( to: current_user.email,
:subject => "commented on post",
:from => "<noreply@xxx.com>")
end
Run Code Online (Sandbox Code Playgroud)
它在本地服务器上工作正常,但在生产中我收到此错误
/home/apps/commentpost/shared/bundle/ruby/2.3.0/gems/sidekiq-4.2.3/lib/sidekiq/processor.rb:69:in `run'
/home/apps/commentpost/shared/bundle/ruby/2.3.0/gems/sidekiq-4.2.3/lib/sidekiq/util.rb:17:in `watchdog'
/home/apps/commentpost/shared/bundle/ruby/2.3.0/gems/sidekiq-4.2.3/lib/sidekiq/util.rb:25:in `block in safe_thread'
2016-11-18T06:47:16.162Z 19093 TID-uw66g ActionMailer::DeliveryJob JID-e56b150964abf082e78089d9 INFO: start
2016-11-18T06:47:16.167Z 19093 TID-uw66g ActionMailer::DeliveryJob JID-e56b150964abf082e78089d9 INFO: fail: 0.005 sec
2016-11-18T06:47:16.167Z 19093 TID-uw66g WARN: {"context":"Job raised exception","job":{"class":"ActiveJob::QueueAdapters::SidekiqAdapter::JobWrapper","wrapped":"ActionMailer::DeliveryJob","queue":"mailers","args":[{"job_class":"ActionMailer::DeliveryJob","job_id":"96e06bc6-1380-47b9-9393-9727868b3897","queue_name":"mailers","priority":null,"arguments":["CommentNotification","send_comment_email","deliver_later",{"_aj_globalid":"gid://commentpost/comment/40"},{"_aj_globalid":"gid://commentpost/User/20"}],"locale":"en"}],"retry":true,"jid":"e56b150964abf082e78089d9","created_at":1479450405.8364522,"enqueued_at":1479451636.1602836,"error_message":"Error while trying to deserialize arguments: Couldn't find Comment with 'id'=40","error_class":"ActiveJob::DeserializationError","failed_at":1479450405.8429642,"retry_count":6,"retried_at":1479451636.1668367},"jobstr":"{\"class\":\"ActiveJob::QueueAdapters::SidekiqAdapter::JobWrapper\",\"wrapped\":\"ActionMailer::DeliveryJob\",\"queue\":\"mailers\",\"args\":[{\"job_class\":\"ActionMailer::DeliveryJob\",\"job_id\":\"96e06bc6-1380-47b9-9393-9727868b3897\",\"queue_name\":\"mailers\",\"priority\":null,\"arguments\":[\"CommentNotification\",\"send_comment_email\",\"deliver_later\",{\"_aj_globalid\":\"gid://commentpost/comment/40\"},{\"_aj_globalid\":\"gid://commentpost/User/20\"}],\"locale\":\"en\"}],\"retry\":true,\"jid\":\"e56b150964abf082e78089d9\",\"created_at\":1479450405.8364522,\"enqueued_at\":1479451636.1602836,\"error_message\":\"Error while trying to deserialize arguments: Couldn't find Comment with 'id'=40\",\"error_class\":\"ActiveJob::DeserializationError\",\"failed_at\":1479450405.8429642,\"retry_count\":5,\"retried_at\":1479450981.998904}"}
2016-11-18T06:47:16.167Z 19093 TID-uw66g WARN: ActiveJob::DeserializationError: …Run Code Online (Sandbox Code Playgroud) 我有一个像这样的字符串:
??? ?afs? ??seg?? ?? y34????
Run Code Online (Sandbox Code Playgroud)
特别是,我想要一个函数(如正则表达式)来回显JUST波斯语字符.
所以,输出应该是:
??? ?? ???? ?? ????
Run Code Online (Sandbox Code Playgroud)
我发现我们可以使用下面的正则表达式,但我不能使用它与功能,它不起作用.
我尝试的正则表达式:
preg_match("(^[\x{0600}-\x{06FF}]*$)", $title);
Run Code Online (Sandbox Code Playgroud)
错误:编译失败:\ x {}或\ o {}中的字符值在偏移处太大
我能做什么,我该怎么办?
TNX.
I am working on Chapter 10 of the Rails Tutorial. I've skipped the account activation and implemented the password reset mailer. Here is the code: of user_mailer_preview.rb
# Preview all emails at http://localhost:3000/rails/mailers/user_mailer
class UserMailerPreview < ActionMailer::Preview
# Preview this email at
# http://localhost:3000/rails/mailers/user_mailer/password_reset
def password_reset
user = User.first
user.reset_token = User.new_token
UserMailer.password_reset(user)
end
end
Run Code Online (Sandbox Code Playgroud)
Here is the code of the user mailer itself:
class UserMailer < ActionMailer::Base
default from: "from@example.com"
# Subject can be set in your I18n file …Run Code Online (Sandbox Code Playgroud)