Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails devise mail

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.

like image 731
jack Avatar asked Nov 23 '11 14:11

jack


1 Answers

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.

like image 64
rogal111 Avatar answered Oct 24 '22 08:10

rogal111