Rails develops mail

I am trying to override the application to send mail to activate the user. In the create method in the registration 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 way to activate the user. Whether this is a good way to verify your account does not matter. The problem is that when I start Pony.mail (...) I get this error

 uninitialized constant RegistrationsController::Pony 

I installed pony and Pony.mail works in the console. I also tried using a β€œpony” at 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.

+6
source share
1 answer

This seems like a packer problem. Are you starting the console in the same RAILS_ENV as your control test?

Try copying pony.rb to your lib (from https://github.com/benprew/pony ) and request it at the top of the controller file. Remove the gem "pony" from your gemfile. bundle install . Take a test.

If this helps, return to the provider, delete Gemfile.lock and run bundle install .

If this problem occurs, include your Gemfile here.

+2
source

Source: https://habr.com/ru/post/902213/


All Articles