Answer: In newer versions of Rails, validation errors are not displayed unless a proper status code is set when rendering the form again. The issue occurs because render :new alone does not trigger the validation error messages correctly.
Solution: Ensure that when render :new is used, the status code is explicitly set to :unprocessable_entity (422).
Updated Code:
def create @foo = FooForm.new(foo_params)
if @foo.save redirect_to @foo, notice: 'Foo was successfully created.' else render :new, status: :unprocessable_entity end end
Why This Works? Without status: :unprocessable_entity, Rails may treat the response as a successful request, preventing error messages from appearing. Setting the correct status code (422) ensures that Rails properly handles validation failures and re-renders the form with errors.