I have a has_one_attached :photo association on my recipe model. This allows users to upload a file when submitting my 'recipe form'. I would like to display errors on the page when the user does not include any of the required fields, photo being one. Errors for the text inputs being empty are working just fine; I'm able to update the redux errors slice of state and display those errors using react.
The issue comes when trying to submit the form without having attached a photo. Rails gives the following error:
Started POST "/api/recipes" for ::1 at 2021-12-21 16:16:09 -0800
Processing by Api::RecipesController#create as JSON
Parameters: {"recipe"=>{"title"=>"aa", "body"=>"ssf", "author_id"=>"19",
"photo"=>"null"}}
Completed 500 Internal Server Error in 3ms (ActiveRecord: 0.0ms)
ActiveSupport::MessageVerifier::InvalidSignature -
ActiveSupport::MessageVerifier::InvalidSignature:
app/controllers/api/recipes_controller.rb:3:in `create'
Does anyone have thoughts on how to handle this error differently from other errors? I'm happy to show my controller, routes, or anything else that may be useful - they are working for all errors other than this one for not having a file attached though, as mentioned.