Michael
Joined
210 Experience
2 Lessons Completed
0 Questions Solved
Activity
For those who are using Rails 7:
Rails 7 has Hotwire enabled by default, and it will validate the response status code. For failed validation, the status code should be 422 (Unprocesssable entity). Otherwise, Hotwire may believe the form is valid, hence it doesn't work.
So in you registrations_controller create method, instead of
else
render :new
end
add a status option
else
render :new, status: :unprocessable_entity
end
This way Hotwire knows "Hey, the form is invalid", and the validation shall work.