I am using formData to send form fields that includes an Image to my rails API. so far it works well but whenever I send that formData that doesn't include an Image I get this error ActiveSupport::MessageVerifier::InvalidSignature (ActiveSupport::MessageVerifier::InvalidSignature): in my rails app. My controller looks like this
def create
@transaction = @current_user.wallet.transactions.new(transaction_params)
if @transaction.save
render json: @transaction, status: :created
else
render json: @transaction.errors, status: :unprocessable_entity
end
end
def transaction_params
params.require(:transaction).permit(:amount, :coin_type, :status, :address, :transaction_type, :receipt )
end
the model looks like this
class Transaction < ApplicationRecord
has_one_attached :receipt
belongs_to :wallet
enum :coin_type, {BITCOIN: 0, ETHERUM: 1, "USD THETHER" => 2}
enum :status, {pending: 0, completed: 1}
enum :transaction_type, {deposit: 0, withdraw: 1}
before_create :valid_transaction?
def valid_transaction?
raise ActiveRecord::RecordNotSaved, "You have limited funds in your wallet" unless amount < wallet.wallet_balance || transaction_type == "deposit"
true
end
def receipt_url
Rails.application.routes.url_helpers.url_for(receipt) if receipt.attached?
end
end
this image is stored in the receipt params