Skip to content

Commit

Permalink
fix: showcase getting email id (#27)
Browse files Browse the repository at this point in the history
  • Loading branch information
drish authored Aug 23, 2024
1 parent 883e594 commit 91d159e
Show file tree
Hide file tree
Showing 4 changed files with 91 additions and 115 deletions.
4 changes: 2 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ git_source(:github) { |repo| "https://github.com/#{repo}.git" }
ruby ">3.0"

# Bundle edge Rails instead: gem "rails", github: "rails/rails", branch: "main"
gem "rails", "~> 7.1.0"
gem "rails", "~> 7.0.0"

# Use sqlite3 as the database for Active Record
gem "sqlite3", "~> 2.0"
gem "sqlite3", "~> 1.4"

# Use the Puma web server [https://github.com/puma/puma]
gem "puma", "~> 5.6"
Expand Down
187 changes: 81 additions & 106 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,104 +1,90 @@
GEM
remote: https://rubygems.org/
specs:
actioncable (7.1.3)
actionpack (= 7.1.3)
activesupport (= 7.1.3)
actioncable (7.0.4)
actionpack (= 7.0.4)
activesupport (= 7.0.4)
nio4r (~> 2.0)
websocket-driver (>= 0.6.1)
zeitwerk (~> 2.6)
actionmailbox (7.1.3)
actionpack (= 7.1.3)
activejob (= 7.1.3)
activerecord (= 7.1.3)
activestorage (= 7.1.3)
activesupport (= 7.1.3)
actionmailbox (7.0.4)
actionpack (= 7.0.4)
activejob (= 7.0.4)
activerecord (= 7.0.4)
activestorage (= 7.0.4)
activesupport (= 7.0.4)
mail (>= 2.7.1)
net-imap
net-pop
net-smtp
actionmailer (7.1.3)
actionpack (= 7.1.3)
actionview (= 7.1.3)
activejob (= 7.1.3)
activesupport (= 7.1.3)
actionmailer (7.0.4)
actionpack (= 7.0.4)
actionview (= 7.0.4)
activejob (= 7.0.4)
activesupport (= 7.0.4)
mail (~> 2.5, >= 2.5.4)
net-imap
net-pop
net-smtp
rails-dom-testing (~> 2.2)
actionpack (7.1.3)
actionview (= 7.1.3)
activesupport (= 7.1.3)
nokogiri (>= 1.8.5)
racc
rack (>= 2.2.4)
rack-session (>= 1.0.1)
rails-dom-testing (~> 2.0)
actionpack (7.0.4)
actionview (= 7.0.4)
activesupport (= 7.0.4)
rack (~> 2.0, >= 2.2.0)
rack-test (>= 0.6.3)
rails-dom-testing (~> 2.2)
rails-html-sanitizer (~> 1.6)
actiontext (7.1.3)
actionpack (= 7.1.3)
activerecord (= 7.1.3)
activestorage (= 7.1.3)
activesupport (= 7.1.3)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.2.0)
actiontext (7.0.4)
actionpack (= 7.0.4)
activerecord (= 7.0.4)
activestorage (= 7.0.4)
activesupport (= 7.0.4)
globalid (>= 0.6.0)
nokogiri (>= 1.8.5)
actionview (7.1.3)
activesupport (= 7.1.3)
actionview (7.0.4)
activesupport (= 7.0.4)
builder (~> 3.1)
erubi (~> 1.11)
rails-dom-testing (~> 2.2)
rails-html-sanitizer (~> 1.6)
activejob (7.1.3)
activesupport (= 7.1.3)
erubi (~> 1.4)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.1, >= 1.2.0)
activejob (7.0.4)
activesupport (= 7.0.4)
globalid (>= 0.3.6)
activemodel (7.1.3)
activesupport (= 7.1.3)
activerecord (7.1.3)
activemodel (= 7.1.3)
activesupport (= 7.1.3)
timeout (>= 0.4.0)
activestorage (7.1.3)
actionpack (= 7.1.3)
activejob (= 7.1.3)
activerecord (= 7.1.3)
activesupport (= 7.1.3)
activemodel (7.0.4)
activesupport (= 7.0.4)
activerecord (7.0.4)
activemodel (= 7.0.4)
activesupport (= 7.0.4)
activestorage (7.0.4)
actionpack (= 7.0.4)
activejob (= 7.0.4)
activerecord (= 7.0.4)
activesupport (= 7.0.4)
marcel (~> 1.0)
activesupport (7.1.3)
base64
bigdecimal
mini_mime (>= 1.1.0)
activesupport (7.0.4)
concurrent-ruby (~> 1.0, >= 1.0.2)
connection_pool (>= 2.2.5)
drb
i18n (>= 1.6, < 2)
minitest (>= 5.1)
mutex_m
tzinfo (~> 2.0)
base64 (0.2.0)
bigdecimal (1.4.4)
bootsnap (1.18.3)
msgpack (~> 1.2)
builder (3.2.4)
builder (3.3.0)
coderay (1.1.3)
concurrent-ruby (1.2.3)
connection_pool (2.4.1)
concurrent-ruby (1.3.3)
crass (1.0.6)
csv (0.1.0)
date (3.3.4)
debug (1.9.1)
irb (~> 1.10)
reline (>= 0.3.8)
drb (2.2.0)
ruby2_keywords
erubi (1.12.0)
erubi (1.13.0)
globalid (1.2.1)
activesupport (>= 6.1)
httparty (0.22.0)
csv
mini_mime (>= 1.0.0)
multi_xml (>= 0.5.2)
i18n (1.14.1)
i18n (1.14.5)
concurrent-ruby (~> 1.0)
io-console (0.7.2)
irb (1.11.2)
Expand All @@ -112,26 +98,23 @@ GEM
net-imap
net-pop
net-smtp
marcel (1.0.2)
marcel (1.0.4)
method_source (1.0.0)
mini_mime (1.1.5)
minitest (5.22.2)
minitest (5.23.1)
msgpack (1.7.2)
multi_xml (0.6.0)
mutex_m (0.2.0)
net-imap (0.4.10)
net-imap (0.4.12)
date
net-protocol
net-pop (0.1.2)
net-protocol
net-protocol (0.2.2)
timeout
net-smtp (0.4.0.1)
net-smtp (0.5.0)
net-protocol
nio4r (2.7.0)
nokogiri (1.16.2-x86_64-darwin)
racc (~> 1.4)
nokogiri (1.16.2-x86_64-linux)
nokogiri (1.16.6-arm64-darwin)
racc (~> 1.4)
pry (0.14.2)
coderay (~> 1.1)
Expand All @@ -140,66 +123,58 @@ GEM
stringio
puma (5.6.8)
nio4r (~> 2.0)
racc (1.7.3)
racc (1.8.0)
rack (2.2.8)
rack-session (1.0.2)
rack (< 3)
rack-test (2.1.0)
rack (>= 1.3)
rackup (1.0.0)
rack (< 3)
webrick
rails (7.1.3)
actioncable (= 7.1.3)
actionmailbox (= 7.1.3)
actionmailer (= 7.1.3)
actionpack (= 7.1.3)
actiontext (= 7.1.3)
actionview (= 7.1.3)
activejob (= 7.1.3)
activemodel (= 7.1.3)
activerecord (= 7.1.3)
activestorage (= 7.1.3)
activesupport (= 7.1.3)
rails (7.0.4)
actioncable (= 7.0.4)
actionmailbox (= 7.0.4)
actionmailer (= 7.0.4)
actionpack (= 7.0.4)
actiontext (= 7.0.4)
actionview (= 7.0.4)
activejob (= 7.0.4)
activemodel (= 7.0.4)
activerecord (= 7.0.4)
activestorage (= 7.0.4)
activesupport (= 7.0.4)
bundler (>= 1.15.0)
railties (= 7.1.3)
railties (= 7.0.4)
rails-dom-testing (2.2.0)
activesupport (>= 5.0.0)
minitest
nokogiri (>= 1.6)
rails-html-sanitizer (1.6.0)
loofah (~> 2.21)
nokogiri (~> 1.14)
railties (7.1.3)
actionpack (= 7.1.3)
activesupport (= 7.1.3)
irb
rackup (>= 1.0.0)
railties (7.0.4)
actionpack (= 7.0.4)
activesupport (= 7.0.4)
method_source
rake (>= 12.2)
thor (~> 1.0, >= 1.2.2)
zeitwerk (~> 2.6)
rake (13.1.0)
thor (~> 1.0)
zeitwerk (~> 2.5)
rake (13.2.1)
rdoc (6.6.2)
psych (>= 4.0.0)
reline (0.4.2)
io-console (~> 0.5)
resend (0.13.0)
httparty (>= 0.21.0)
ruby2_keywords (0.0.5)
sqlite3 (2.0.0-x86_64-darwin)
sqlite3 (2.0.0-x86_64-linux-gnu)
sqlite3 (1.7.3-arm64-darwin)
stringio (3.1.0)
thor (1.3.0)
thor (1.3.1)
timeout (0.4.1)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
webrick (1.8.1)
websocket-driver (0.7.6)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.5)
zeitwerk (2.6.13)
zeitwerk (2.6.15)

PLATFORMS
arm64-darwin-22
x86_64-darwin-20
x86_64-linux

Expand All @@ -208,9 +183,9 @@ DEPENDENCIES
debug
pry
puma (~> 5.6)
rails (~> 7.1.0)
rails (~> 7.0.0)
resend
sqlite3 (~> 2.0)
sqlite3 (~> 1.4)
tzinfo-data

RUBY VERSION
Expand Down
7 changes: 5 additions & 2 deletions app/controllers/user_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@ class UserController < ApplicationController
def send_hello_email
@user = User.new(name: "derich")

r = UserMailer.with(user: @user).welcome_email.deliver!
render json: {status: 'ok'}
resp = UserMailer.with(user: @user).welcome_email.deliver!

render json: {
email_id: resp[:id]
}
end

def healthz
Expand Down
8 changes: 3 additions & 5 deletions app/mailers/user_mailer.rb
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
class UserMailer < ApplicationMailer
# this domain must be verified with Resend
default from: "from@example.com"
default from: "onboarding@resend.dev"

def welcome_email
@user = params[:user]
attachments["invoice.pdf"] = File.read(Rails.root.join("resources","invoice.pdf"))
@url = "http://example.com/login"
mail(
to: ["to@example.com"],
cc: ["cc@example.com"],
bcc: ["bcc@example.com"],
reply_to: "replyto@example.com",
to: ["delivered@resend.dev"],
reply_to: "delivered@resend.dev",
subject: "Hello from Rails",
)
end
Expand Down

0 comments on commit 91d159e

Please sign in to comment.