假设我有一堆“电子邮件”功能-比如用户注册确认或密码恢复电子邮件,或通知更新电子邮件。我可以在哪里“放置”这些函数?我最初的想法是简单地将它们放在控制器中,但我更愿意有一个公共的地方。然后我的想法是专门为电子邮件创建一个新的控制器,但这打破了MVC模式,我的最后一个想法是扩展email_helper.php助手,但如果我这样做了,我就不能做像这样的事情
$this->email->to($email);
因为我得到了一个错误:
Fatal error: Using $this when not in object context in /Applications/XAMPP/xam
我有一个Drupal8站点,并且我刚刚安装了Sparkpost模块(https://www.drupal.org/project/sparkpost)。 在Drupal中这个模块的设置屏幕上,我看到了以下消息; You seem to be using php_mail as your mail system instead of sparkpost_mail. If this is not on purpose, you should change the configration for interface.default in system.mail to sparkpost_mail
基本上,我所需要的只是我的业务表中的一个template_id字段,以便正确分配,这样如果我做了Business.first.template,它就会返回当前为该业务分配的模板的结果。在我明白的时候,我只是得到了“零”
在我的项目中,业务belongs_to是一个模板(我相信这会将主键放在模板表中,外键放在业务表中)。
class Business < ActiveRecord::Base
belongs_to :template
class Template < ActiveRecord::Base
has_many :businesses
当用户为“新业务”填写表单时,他们会