Advertisement
Guest User

Untitled

a guest
Apr 5th, 2016
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.53 KB | None | 0 0
  1. # environment.rb
  2. # Load the Rails application.
  3. require File.expand_path('../application', __FILE__)
  4.  
  5. # Initialize the Rails application.
  6. Rails.application.initialize!
  7.  
  8. ActionMailer::Base.smtp_settings = {
  9. user_name: 'your_sendgrid_username',
  10. password: 'your_sendgrid_password',
  11. domain: 'yourdomain.com',
  12. address: 'smtp.sendgrid.net',
  13. port: 587,
  14. authentication: :plain,
  15. enable_starttls_auto: true
  16. }
  17.  
  18. class UserMailer < ApplicationMailer
  19. default from: 'notifications@example.com'
  20.  
  21. def welcome_email(user)
  22. @user = user
  23. @url = 'http://example.com/login'
  24. mail(to: @user.email, subject: 'Welcome to My Awesome Site')
  25. end
  26. end
  27.  
  28. class UsersController < ApplicationController
  29. def index
  30. @users = User.all
  31. end
  32.  
  33. def new
  34. @user = User.new
  35. end
  36.  
  37. def create
  38. @user = User.new(user_params)
  39. if @user.save
  40. UserMailer.welcome_email(@user).deliver
  41. session[:current_user_id] = @user.token
  42. redirect_to root_path
  43. else
  44. render :new
  45. end
  46. end
  47.  
  48. private
  49.  
  50. def user_params
  51. params.require(:user).permit(:email, :password, :first_name, :last_name, :login)
  52. end
  53. end
  54.  
  55. doctype html
  56.  
  57. html
  58. head
  59. meta content='text/html; charset=UTF-8' http-equiv='Content-Type'
  60. body
  61. Welcome to example.com,
  62. = @user.name
  63. p
  64. You have successfully signed up to example.com,
  65. your username is:
  66. = @user.login
  67. p
  68. To login to the site, just follow this link: = @url
  69. p
  70. Thanks for joining and have a great day!
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement