Rails 设计邮件

发布于 2024-12-17 18:48:18 字数 987 浏览 4 评论 0原文

我正在尝试覆盖设计以发送邮件来激活用户。在注册控制器的创建方法中,我有这个

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

所有深爱都是秘密 2024-12-24 18:48:18

看起来像是捆绑器的问题。您是否在与控制器测试相同的 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文