title: Paperclip can't save to S3 and database
body: <p>gem is
  ・gem 'devise'
  ・gem 'paperclip'
  ・gem 'aws-sdk', '~> 2.3'
  rails version is rails5
  Metadata is not saved in the database and it is not reflected in S3.
  I tried various studies and tried, but none goes well.</p>
  
  <p>database User table</p>
  
  <pre><code> create_table "users", force: :cascade do |t|
      t.string "email", default: "", null: false
      t.string "encrypted_password", default: "", null: false
      t.string "reset_password_token"
      t.datetime "reset_password_sent_at"
      t.datetime "remember_created_at"
      t.integer "sign_in_count", default: 0, null: false
      t.datetime "current_sign_in_at"
      t.datetime "last_sign_in_at"
      t.string "current_sign_in_ip"
      t.string "last_sign_in_ip"
      t.datetime "created_at", null: false
      t.datetime "updated_at", null: false
      t.string "provider"
      t.string "uid"
      t.string "name"
      t.string "phone_number"
      t.string "description"
      t.string "image"
      t.string "avatar_file_name"
      t.string "avatar_content_type"
      t.integer "avatar_file_size"
      t.datetime "avatar_updated_at"
      t.index ["email"], name: "index_users_on_email", unique: true
      t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true
    end
  </code></pre>
  
  <p>model/user</p>
  
  <pre><code>class User &lt; ApplicationRecord
    devise :database_authenticatable, :registerable,
           :recoverable, :rememberable, :trackable, :validatable, :omniauthable
  
     validates :name, presence: true,uniqueness: true, length: { maximum: 50 }
     validates :email, {presence: true, uniqueness: true}
  
     has_attached_file :avatar,
                       :styles =&gt; { :medium =&gt; "400x400", :thumb =&gt; "100x100&gt;" },
                       :default_url =&gt; "avatar-default.png",
                       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'),
                       }
     validates_attachment_content_type :avatar, :content_type =&gt; /\Aimage\/.*\Z/
  
   def self.from_omniauth(auth)
     where(provider: auth.provider, uid: auth.uid).first_or_create do |user|
       user.email = auth.info.email
       user.password = Devise.friendly_token[0,20]
       user.name = auth.info.name   # assuming the user model has a name
       user.image = "http://graph.facebook.com/#{auth.uid}/picture?type=large" # assuming the user model has an image
       # If you are using confirmable and the provider(s) you use validate emails,
       # uncomment the line below to skip the confirmation emails.
       # user.skip_confirmation!
     end
   end
  end
  </code></pre>
  
  <p>users_controller</p>
  
  <pre><code>class UsersController &lt; ApplicationController
   before_action :authenticate_user
  
    def edit
      @user = User.find_by(id: params[:id])
    end
  
    def update
      @user = User.find(params[:id])
  
      if @user.update(user_params)
        flash[:notice] = "can edit"
        redirect_to("/users/#{@user.id}")
      else
        flash[:notice] = "Can't edit"
        redirect_to("/users/#{@user.id}/edit")
      end
    end
  
   private
  
   def user_params
     params.require(:user).permit(:avatar, :name, :email, :phone_number, :description, :college_name)
   end
  
  end
  </code></pre>
  
  <p>edit.html.erb</p>
  
  <pre><code>&lt;%= form_tag("/users/#{@user.id}/update", html:{multipart: true}) do %&gt;
  
              &lt;div class="form-group"&gt;
                &lt;p&gt;*name&lt;/p&gt;
                &lt;input name="user[name]" value="&lt;%= @user.name %&gt;" class="form-control"&gt;
              &lt;/div&gt;
  
              &lt;div class="form-group"&gt;
                &lt;p&gt;*email&lt;/p&gt;
                &lt;input name=user[email] value="&lt;%= @user.email %&gt;" class="form-control"&gt;
              &lt;/div&gt;
  
              &lt;div class="form-group"&gt;
                &lt;p&gt;avatar&lt;/p&gt;
                &lt;%= file_field_tag :avatar, class: "form-control" %&gt;
              &lt;/div&gt;
  
              &lt;div class="form-group"&gt;
                &lt;p&gt;phone number&lt;/p&gt;
                &lt;input name=user[phone_number] value="&lt;%= @user.phone_number %&gt;" class="form-control"&gt;
              &lt;/div&gt;
  
              &lt;div class="form-group"&gt;
                &lt;p&gt;description&lt;/p&gt;
                &lt;textarea name=user[description] class="form-control" rows="8" cols="80"&gt;&lt;%= @user.description %&gt;&lt;/textarea&gt;
              &lt;/div&gt;
  
              &lt;div class="actions"&gt;
                &lt;input type="submit" value="Edit" class="btn btn-primary"&gt;
              &lt;/div&gt;
  
  &lt;% end %&gt;
  </code></pre>
  
  <p>For config / environments development and production</p>
  
  <pre><code>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'),
    }
  }
  </code></pre>
  
  <p>his is described as follows.
  Information on this is written in config / application.yml.
  How do I edit it?
  I would appreciate it if possible to tell me as much as possible.
  Thank you.</p>