Rails 设计邮件
我正在尝试覆盖设计以发送邮件来激活用户。在注册控制器的创建方法中,我有这个
urlEmail = resource.email.sub('@','-')
Pony.mail(
:to => resource.email,
:from => "[email protected]",
:subject => "Confirm Account",
:headers => { 'Content-Type' => 'text/html' },
:body => ("<h1>Welcome To My Awesome Site</h1>
<p>follow this link to create your account</p>
<p>http://localhost:3000/confirm-me/stuff?=" + resource.confirmhash.to_s + "/" + urlEmail.to_s + "</p>") )
这个 url 导致激活用户的方法。这是否是确认帐户的好方法不是重点。问题是,当 Pony.mail(...) 运行时,我收到此错误,
uninitialized constant RegistrationsController::Pony
我已经安装了 pony 并且 Pony.mail 在控制台中工作。我还尝试在控制器文件顶部使用 require 'pony' 但我得到了
no such file to load -- pony
我需要做什么才能完成这项工作。
Im trying to override devise in order to send mail to activate a user. In the create method in the registrations controller i have this
urlEmail = resource.email.sub('@','-')
Pony.mail(
:to => resource.email,
:from => "[email protected]",
:subject => "Confirm Account",
:headers => { 'Content-Type' => 'text/html' },
:body => ("<h1>Welcome To My Awesome Site</h1>
<p>follow this link to create your account</p>
<p>http://localhost:3000/confirm-me/stuff?=" + resource.confirmhash.to_s + "/" + urlEmail.to_s + "</p>") )
This url leads to a method to activate the user. Whether this is a good way to confirm an account is beside the point. The problem is that when the Pony.mail(...) runs i get this error
uninitialized constant RegistrationsController::Pony
i have installed pony and Pony.mail works in the console. I also tried using require 'pony' in the top of the controller file but i get
no such file to load -- pony
What do i need to do to make this work.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看起来像是捆绑器的问题。您是否在与控制器测试相同的 RAILS_ENV 中运行控制台?
尝试将 pony.rb 复制到您的库(来自 https://github.com/benprew/pony)并要求它位于控制器文件的顶部。从 Gemfile 中删除
gem“pony”
。捆绑安装
。做一个测试。如果有帮助,请返回捆绑程序,删除 Gemfile.lock 并运行
bundle install
。如果仍然存在此问题,请在此处包含您的 Gemfile。
It's look like problem with bundler. Do you run console in the same RAILS_ENV as your controller test?
Try to copy pony.rb to your lib (from https://github.com/benprew/pony) and require it on the top of controller file. Remove
gem "pony"
from your Gemfile.bundle install
. Make a test.If its help, go back to bundler, remove Gemfile.lock and run
bundle install
.If still have this problem include your Gemfile here.