【问题标题】:Rails App Notification PluginsRails 应用通知插件
【发布时间】:2010-11-25 06:33:20
【问题描述】:

谁能推荐一些 Rails 插件,让我可以针对模型注册各种通知,这些模型可以链接到一组模板以格式化电子邮件(可能还有其他)。

理想情况下,插件可以在每个模型的一行中引用,并且通知格式可以从某些构造传递,例如用户偏好等。

感谢您的帮助

Dom

【问题讨论】:

标签: ruby-on-rails ruby-on-rails-plugins


【解决方案1】:

observational 是一种很好的观察方式:)

class Notifier < ActionMailer::Base
  observes :user, :after => :create, :invokes => :deliver_welcome_email

  def welcome_email(user)
  end
end

【讨论】:

    【解决方案2】:

    我不知道你为什么需要一个插件,因为它可以通过ActiveRecord Callbacks 完成,在每个模型中设置一个回调,比如

    after_save :send_notifications
    
    def send_notifications
      Notifier.deliver_signup_notification(template, user) # sends the email
    end
    

    如果不是由应用程序的逻辑决定的,您需要滚动自己的界面来创建和选择 HTML 模板。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2010-10-20
      • 2016-02-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-09-26
      相关资源
      最近更新 更多