I'm trying to store images using AmazonS3 for my blog using paperclip. The blog has devise gem implemented for login/signup [User] and I want to add image for every user by storing them on Amazon S3. Previously I was storing them in Database and it was working perfectly.
I've already searched a lot but couldn't find a fix for this.
        //Development.rb
    config.paperclip_defaults = {
      storage: :s3,
        s3_credentials: {
          bucket: ENV.fetch('S3_BUCKET_NAME'),
          access_key_id: ENV.fetch('AWS_ACCESS_KEY_ID'),
          secret_access_key: ENV.fetch('AWS_SECRET_ACCESS_KEY'),
          s3_region: ENV.fetch('AWS_REGION'),
        }
      }
    //AddAttachment Migration
    class AddAttachmentImageToUsers < ActiveRecord::Migration[5.2]
      def self.up
        change_table :users do |t|
          t.attachment :image
        end
      end
      def self.down
        remove_attachment :users, :image
      end
    end
    //User.rb
    class User < ActiveRecord::Base
      # Include default devise modules. Others available are:
      # :confirmable, :lockable, :timeoutable, :trackable and :omniauthable
      devise :database_authenticatable, :registerable,
             :recoverable, :rememberable, :validatable
      has_many :comments, dependent: :destroy
      has_many :likes, dependent: :destroy
      has_many :articles
      has_attached_file :image, :styles => { :medium => "300x300>", :thumb => "100x100>"}
      validates_attachment_content_type :image, content_type: /\Aimage\/.*\z/
    end
    //Application.yml
    AWS_ACCESS_KEY_ID: -----
    AWS_SECRET_ACCESS_KEY: ------
    S3_BUCKET_NAME: -------------
    AWS_REGION: ap-south-1
    //Application.html.erb
   <!DOCTYPE html>
<html>
  <head>
    <title> TheBlog</title>
    <%= csrf_meta_tags %>
    <%= csp_meta_tag %>
    <%= stylesheet_link_tag    'application', media: 'all', 'data-turbolinks-track': 'reload' %>
    <%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
  </head>
  <body>
    <nav class="navbar navbar-inverse">
  <div class="container-fluid">
    <div class="navbar-header">
      <a class="navbar-brand" href="#" id="logo">The Blog</a>
    </div>
    <ul class="nav navbar-nav">
      <li class="active">
        <%= link_to 'Home', root_path %></li>
        <li><%= link_to 'About', about_path %></li>
    </ul>
    <ul class="nav navbar-nav navbar-right">
      <% if user_signed_in? %>
        <li>  <%= image_tag current_user.image.url, size:"40x40" %></li>
        <li><%= link_to current_user.email, edit_user_registration_path %></li>
        <li><%= link_to "Logout", destroy_user_session_path, method: :delete %></li>
        <% else %>
      <li><%= link_to "Sign Up", new_user_registration_path %></li>
      <li><%= link_to "Login", new_user_session_path %></li>
      <% end %>
    </ul>
  </div>
</nav>
    <%= yield %>
  </body>
</html>