0

I want to be able to send a users username and password when a user is creating anoter user in Devise. When say, admin creates a new user. A welcome mail should go with his username and password. The catch is it should only happen for users created by admin and other users should get regular devise confirmation mail. It will be greated if we are able to skip confirmation for users created by admin alone. Any ideas?

Aravind
  • 1,391
  • 1
  • 16
  • 41
  • check out this question: http://stackoverflow.com/questions/18775887/devise-different-email-when-manually-registered/18782740#18782740 - I think that should help you. – Matthias Sep 21 '13 at 21:28
  • @Mattherick I am not able to understand how to set a helper variable. The admin is not a seperate model. It is a role, that is all. – Aravind Sep 21 '13 at 21:34
  • You must not set a helper variable. In your case I would simple add an if to the user create action.. "if current_user.admin? (has_role? admin..your method to check if the current user is an admin)".. if yes, sent the "special" mail, if not, sent the other mail. Do you know what I mean? – Matthias Sep 21 '13 at 21:37
  • Oh okay. Thing is that I have created a separate create_user page for the admin. For all other confirmation mail should be normal for the people admin creates alone I need a different view. I get the current_user.has_role? :admin part. How can I override the mailer view for this particular instance alone? – Aravind Sep 21 '13 at 21:42
  • Simple create the devise views with "bundle exec rails generate devise:views" - like in the other post mentioned, and you will get a "devise" folder under /app/views - and this folder contains all devise views and you can simple overwrite them. – Matthias Sep 21 '13 at 21:47
  • @Mattherick It is not detecting current_user in the confirmation mailer view. – Aravind Sep 22 '13 at 03:33

0 Answers0