Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class ApplicationMailer < ActionMailer::Base
- default sender: "ben@thorcinemas.com"
- layout 'mailer'
- end
- class UserMailer < ApplicationMailer
- default from: 'notifications@example.com'
- def welcome_email(user)
- @user = user
- @url = 'http://localhost:3000/users/login'
- mail(to: @user.email, subject: 'Welcome to My Awesome Site')
- end
- end
- <!DOCTYPE html>
- <html>
- <head>
- <meta content='text/html; charset=UTF-8' http-equiv='Content-Type' />
- </head>
- <body>
- <h1>Welcome to example.com, <%= @user.first_name %></h1>
- <p>
- You have successfully signed up to example.com,
- your username is: <%= @user.first_name %><%= @user.last_name %>.<br>
- </p>
- <p>
- To login to the site, just follow this link: <%= @url %>.
- </p>
- <p>Thanks for joining and have a great day!</p>
- </body>
- </html>
- Welcome to example.com, <%= @user.first_name %>
- ===============================================
- You have successfully signed up to example.com,
- your username is: <%= @user.first_name %><%= @user.last_name %>.
- To login to the site, just follow this link: <%= @url %>.
- Thanks for joining and have a great day!
- def create
- @user = User.new(user_params)
- if @user.save
- # login is achieved by saving a user's 'id' in a session variable,
- # accessible to all pages
- session[:user_id] = @user.id
- UserMailer.welcome_email(@user).deliver_later
- redirect_to films_path
- else
- render action: "new"
- end
- end
- create_table "users", force: :cascade do |t|
- t.string "password_digest"
- t.string "role"
- t.datetime "created_at", null: false
- t.datetime "updated_at", null: false
- t.string "first_name"
- t.string "last_name"
- t.string "house_no"
- t.string "street"
- t.string "town"
- t.string "postcode"
- t.string "email"
- t.date "date_of_birth"
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement