Devise - Different email when manually registered

左心房为你撑大大i 提交于 2019-12-06 15:48:54

问题


I want to give the administrator the ability to manually register new users.

Everything goes fine by just creating a new user in the admin action but I want to send a different email to these users than the one being sent to those who registered following the normal procedure.

Any ideas?


回答1:


I think you can skip sending the original confirmation mail in your admin action. Simple create your own mailer action and send your desired mail.

Maybe it is also possible to create a normal confirmation mail, but modify the mail output.

bundle exec rails generate devise:views

And after that modify the text in "app/views/devise/mailer/confirmation_instructions.html.erb

<% if @sent_by_admin == true %>
  ...admin mailer text...
<% else %>
  ...normal mailer text...
<% end %>

@sent_by_admin could be a helper variable, which is passed to the devise confirmation mailer.




回答2:


I expect you would need to follow the instructions on the [devise page to generate the controllers and then modify your create action to generate the additional email.



来源:https://stackoverflow.com/questions/18775887/devise-different-email-when-manually-registered

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!