Advertisement
Guest User

Untitled

a guest
Mar 1st, 2015
215
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.87 KB | None | 0 0
  1. class ApplicationMailer < ActionMailer::Base
  2. default sender: "ben@thorcinemas.com"
  3. layout 'mailer'
  4. end
  5.  
  6. class UserMailer < ApplicationMailer
  7. default from: 'notifications@example.com'
  8.  
  9. def welcome_email(user)
  10. @user = user
  11. @url = 'http://localhost:3000/users/login'
  12. mail(to: @user.email, subject: 'Welcome to My Awesome Site')
  13. end
  14. end
  15.  
  16. <!DOCTYPE html>
  17. <html>
  18. <head>
  19. <meta content='text/html; charset=UTF-8' http-equiv='Content-Type' />
  20. </head>
  21. <body>
  22. <h1>Welcome to example.com, <%= @user.first_name %></h1>
  23. <p>
  24. You have successfully signed up to example.com,
  25. your username is: <%= @user.first_name %><%= @user.last_name %>.<br>
  26. </p>
  27. <p>
  28. To login to the site, just follow this link: <%= @url %>.
  29. </p>
  30. <p>Thanks for joining and have a great day!</p>
  31. </body>
  32. </html>
  33.  
  34. Welcome to example.com, <%= @user.first_name %>
  35. ===============================================
  36.  
  37. You have successfully signed up to example.com,
  38. your username is: <%= @user.first_name %><%= @user.last_name %>.
  39.  
  40. To login to the site, just follow this link: <%= @url %>.
  41.  
  42. Thanks for joining and have a great day!
  43.  
  44. def create
  45. @user = User.new(user_params)
  46. if @user.save
  47. # login is achieved by saving a user's 'id' in a session variable,
  48. # accessible to all pages
  49. session[:user_id] = @user.id
  50. UserMailer.welcome_email(@user).deliver_later
  51. redirect_to films_path
  52. else
  53. render action: "new"
  54. end
  55. end
  56.  
  57. create_table "users", force: :cascade do |t|
  58. t.string "password_digest"
  59. t.string "role"
  60. t.datetime "created_at", null: false
  61. t.datetime "updated_at", null: false
  62. t.string "first_name"
  63. t.string "last_name"
  64. t.string "house_no"
  65. t.string "street"
  66. t.string "town"
  67. t.string "postcode"
  68. t.string "email"
  69. t.date "date_of_birth"
  70. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement