【问题标题】:Rails ActionMailer template updates not taking effectRails ActionMailer 模板更新未生效
【发布时间】:2015-08-28 15:05:56
【问题描述】:

我正在对我未参与创建的 Rails 站点进行更改。该站点有一个供新用户注册的表单,该表单会生成一封电子邮件给可以批准新帐户的管理员。

当这些电子邮件的模板发生变化时,生成的电子邮件的内容不会改变。 如何使电子邮件模板的更改生效?

我是 Rails 新手,所以我可能会遗漏一些明显的东西。我相信这些是相关文件:

app/mailers/user_mailer.rb

class UserMailer < ActionMailer::Base
  default from: 'webmaster'

  def new_user_notification_mailer(user, admin_email)
    @user = user
      mail(to: admin_email, subject: 'New User Registration')
  end
end

app/workers/send_new_user_notification_worker.rb

class SendNewUserNotificationWorker
  include Sidekiq::Worker

  def perform(user_id)
    user = User.find(user_id)
    if user
      User.is_admin.each do |admin|
        if admin.email
          UserMailer.new_user_notification_mailer(user, admin.email).deliver
        end
      end
    end
  end
end

app/views/user_mailer/new_user_notification_mailer.html.slim

doctype html
html
  head
    meta content='text/html; charset=UTF-8' http-equiv='Content-Type'
  body
    p
      | New user 
      b #{@user.first_name} #{@user.last_name}
      | has registered on the web site.
    | You can 
    = link_to "Manage", edit_admin_user_url(@user)
    | this account from admin panel.

我一直在用这个重新启动服务器(工作副本的):

RAILS_ENV=production bash -c 'bundle exec rake assets:clean; bundle exec rake bower:resolve; bundle exec rake assets:precompile'; kill `cat tmp/pids/server.pid`; nohup bundle exec rails s -e production -p 4000 1>> log/rails.sever.log 2>> log/rails.server.err.log &

【问题讨论】:

    标签: ruby-on-rails actionmailer


    【解决方案1】:

    您还需要重新启动 sidekiq 进程。它将重新加载您的 rails 环境和 sidekiq 进程的代码更改。在此之后,您的更改应该会反映出来。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-10-10
      • 1970-01-01
      • 1970-01-01
      • 2017-05-27
      • 1970-01-01
      • 2011-11-27
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多