Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tanhongit/send_mail_background_job
Send mail background job Rails 6 with gem sidekiq
https://github.com/tanhongit/send_mail_background_job
backgound-job-mail background-jobs gem-sidekiq rails rails-send-mail rails6 ruby ruby-on-rails sendmail sidekiq tanhongit tanhongit-rails
Last synced: about 1 month ago
JSON representation
Send mail background job Rails 6 with gem sidekiq
- Host: GitHub
- URL: https://github.com/tanhongit/send_mail_background_job
- Owner: tanhongit
- License: mit
- Created: 2020-07-20T10:38:46.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2023-01-19T20:36:26.000Z (about 2 years ago)
- Last Synced: 2024-11-01T23:04:05.941Z (3 months ago)
- Topics: backgound-job-mail, background-jobs, gem-sidekiq, rails, rails-send-mail, rails6, ruby, ruby-on-rails, sendmail, sidekiq, tanhongit, tanhongit-rails
- Language: Ruby
- Homepage: https://tanhongit.github.io/send_mail_background_job/
- Size: 21 MB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 32
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Security: SECURITY.md
Awesome Lists containing this project
README
# Welcome to Rails 6 Send Mail Backgtound Job with gem sidekiq
The Rails 6 Send Mail Backgtound Job is a small task for everyone to practice more when programming with Ruby on Rails.
We will use gem sidekiq to perform this task.
## Support for me
Support this project :stuck_out_tongue_winking_eye: :pray:# 1. Technology
- Ruby on Rails# 2. Configuration requirements
We are going to build the web application using:
- Rails 6.0.3.2
- Ruby 2.7.1# 4. What is background Job
Since you already know the call to your Application will be slow, you want it to happen in a background job, so that users can see the confirmation message in their browser immediately without having to wait for the charge to actually happen. To do this, you must create an Active Job class, implement that class to call charge!(), and then add code to the controller to execute this job. The flow looks like the following figure.![Image](https://imgur.com/Ns3P04e.png)
# 5. Runing
## 5.1. Clone Repo
```
$ git clone https://github.com/TanHongIT/send_mail_background_job
$ cd send_mail_background_job
```### 5.2. Bundle Install
```
$ bundle install
```### 5.3. Yarn Install
```
$ yarn install
```### 5.4. Create database with Postgresql
You must change the appropriate database configuration
Change configuration at _"config/database.yml"_ with Postgresql.
```ruby
default: &default
adapter: postgresql
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
timeout: 5000
username: send_mail_background_job
password: 1234
host: localhost# tutorial for ubuntu linux:
# sudo -u postgres psql
# create user "send_mail_background_job" with password '1234';
# create database "send_mail_background_job" owner "send_mail_background_job";development:
<<: *default
database: send_mail_background_job# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
<<: *default
database: send_mail_background_job_testproduction:
<<: *default
database: send_mail_background_job_production
```You must change the username, password and database name accordingly!
### 5.5. run rails db:migrate
```
$ rails db:migrate
```### 5.6. Change your mail
Run console :
```
$ bundle exec figaro install
```Go to config directory and add to file **"config/application.yml"**
```ruby
user_mail: '[email protected]'
password: 'your password'
```Change your mail in **app/mailers/application_mailer.rb**
```ruby
class ApplicationMailer < ActionMailer::Base
default from: 'your_mail'
layout 'mailer'
end
```### 5.7. Run sidekiq
```
$ bundle exec sidekiq
```### 5.8. Run server
Open new terminal and run:
```
rails s
```Now go to at http://localhost:3000/users/new and put your mail end waiting for a response to arrive
# 6. Demo
![Image](https://imgur.com/xON93Xa.png)