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 => "noreply@mysite.com",
    :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.

有帮助吗?

解决方案

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.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top