1. Login AWS
2. Goes in to LightSail: https://lightsail.aws.amazon.com/ls/webapp/home
3. click from left side menu: Domains & DNS
4. Then select DNS Zone >> select DNS Record
5. Then +Add record
6. And Enter the "Record Name (Record name)" and Save
1. Login AWS
2. Goes in to LightSail: https://lightsail.aws.amazon.com/ls/webapp/home
3. click from left side menu: Domains & DNS
4. Then select DNS Zone >> select DNS Record
5. Then +Add record
6. And Enter the "Record Name (Record name)" and Save
1. Goes to Amazon ECR >> Private registry >> Repositories
2. Create new Repositories
A. Enter the `Namespace/repo-name`
B. Image Tag setting Choose is `Mutable`
C. Encryption configuration >> `AES-256`
3. Then Create
4. https://us-east-2.console.aws.amazon.com/ecr/private-registry/repositories?region=us-east-2
5. Then use this `Namespace` image on deploy.yml for kamal
Is Blog se local se server per data create kar sakte hai.
1. On each EC2 instance, edit the PostgreSQL configuration file
1.1 sudo nano /etc/postgresql/<version>/main/postgresql.conf
# or for Amazon Linux
sudo nano /var/lib/pgsql/<version>/data/postgresql.conf
--
Update this line:
listen_addresses = '*' OR
listen_addresses = '0.0.0.0'
---------------------------------------------------------------
2. Edit pg_hba.conf to Allow Remote Connections
On each instance, edit the pg_hba.conf file:
sudo nano /etc/postgresql/<version>/main/pg_hba.conf
# or
sudo nano /var/lib/pgsql/<version>/data/pg_hba.conf
Add the following line at the end (replace CIDR with the IP or IP range you want to allow):
host all all 0.0.0.0/0 md5
-----------------------------------------------3. Open Port 5432 in EC2 Security Groups(This is most important)
Go to AWS EC2 Console → Security Groups, and for each EC2 instance:
Find the associated Security Group.
Click Inbound rules → Edit inbound rules → Add rule:
Type: PostgreSQL
Protocol: TCP
Port Range: 5432
Source: Custom → <Your IP>/32 (or 0.0.0.0/0 for all IPs, use with caution)
----------------------------------------------------
After making changes:
sudo systemctl restart postgresql
# or
sudo service postgresql restart---------------------------------5. Connect Remotely
Now you can connect from your local machine using a PostgreSQL client:
psql -h IP -U user_name -d database_name
ec2-ip: Server Ip address
username: Server pg username
6. Update Database.yml file
default: &default adapter: postgresql encoding: unicode pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %> username: <%= ENV["DATABASE_USERNAME"] %> password: <%= ENV["DATABASE_PASSWORD"] %> database: <%= ENV["DATABASE_NAME"] %> host: <%= ENV["DATABASE_HOST"] %> development: <<: *default staging: <<: *default test: <<: *default production: <<: *default
Application.yml file
development:
DATABASE_NAME: "database_name" # This is server database name
DATABASE_HOST: "IP"
DATABASE_USERNAME: "Server pg username"
DATABASE_PASSWORD: "Server pg password"
1. ps aux | grep sidekiq
Get output: ubuntu 1111111 0.0 0.0 7008 2432 pts/0 S+ 10:28 0:00 grep --color=auto sidekiq
2. kill -9 1111111
3. bundle exec sidekiq -d -L log/sidekiq.log
4. sudo service redis-server restart
5. sudo systemctl restart sidekiq
Routes:
post "/send_email_with_attachment", to: "articles#send_email_with_attachment"
-----------------------------------
Controller:
class ArticlesController < ApplicationController
def send_email_with_attachment
email = "arvind@gmail.com"
attachment = params[:attachment]
# Save the file temporarily
file_path = Rails.root.join('tmp', attachment.original_filename)
File.open(file_path, 'wb') do |file|
file.write(attachment.read)
end
MyMailer.send_email_with_attachment(email, file_path).deliver_now
# Delete the temporary file after sending the email
File.delete(file_path) if File.exist?(file_path)
redirect_to root_path, notice: 'Email sent successfully'
end
end
--------------------------
Mailer
class MyMailer < ApplicationMailer
def send_email_with_attachment(email, attachment_path)
@greeting = "Hi"
attachments[File.basename(attachment_path)] = File.read(attachment_path)
mail(to: email, subject: 'Email with Attachment')
end
end
-------------------------------
Please visite: https://alex-okorkov.medium.com/how-to-set-up-aws-s3-bucket-on-rails-with-activestorage-d384075ce773
--------------------
Code:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": "*",
"Action": "s3:ListBucket",
"Resource": "arn:aws:s3:::bucket-name"
},
{
"Effect": "Allow",
"Principal": "*",
"Action": [
"s3:PutObject",
"s3:GetObject",
"s3:DeleteObject"
],
"Resource": "arn:aws:s3:::bucket-name/*"
}
]
}
1. Add Gem
gem "nested_form"
rails g nested_form:installjb ye line run karege to public ke ander >> public/javascript/js/nested_form.js file generate hogi, lekin nested_form.js ka code is directory me add kar dena >> app/javascript/js/nested_form.js