ActiveSupport::MessageVerifier::InvalidSignature

I came across this error while trying to edit an avatar in Devise::RegistrationsController#update
I cannot seem to have a work around.
How can I solve this?

** My input field is custom **
<input type="file" accept="image/*" name="customer[avatar]" id="customer_avatar" onchange="loadFile(event)" class="form-control d-none">
<i class="fa fa-camera-retro"></i><label for="customer_avatar">Change picture</label>

*My customer.rb
after_commit :add_default_avatar, on: %i[update]
has_one_attached :avatar

def avatar_thumbnail

    if avatar.attached?

      avatar.variant(resize: "80x82!").processed

    else

      "no_profile.png"

    end

  end

private

  def add_default_avatar

    unless avatar.attached?

      avatar.attach(

        io: File.open(

          Rails.root.join(

            "app", "assets", "images", "no_profile.png"

          )

        ), filename: "no_profile.png",

        content_type: "image/png",

      )

    end

  end

** My application controller **
def configure_permitted_parameters

attributes = [:first_name, :last_name, :phone, [:avatar]]

devise_parameter_sanitizer.permit :sign_up, keys: attributes

devise_parameter_sanitizer.permit :account_update, keys: attributes

end

SOLVED!!

Turns out my form did not have the mutipart: true form enctype attribute

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs