I'm a bit confused by the output in my rails console, and that a Rails API only project is returning HTML errors. I have a controller that is throwing an ActiveRecord Validation Error. In my console output I see:
↳ app/controllers/v1/users/accounts_controller.rb:7:in `create'
Completed 422 Unprocessable Entity in 324ms (ActiveRecord: 30.9ms | Allocations: 15443)
ActiveRecord::RecordInvalid (Validation failed: Password is too short (minimum is 8 characters)):
app/controllers/v1/users/accounts_controller.rb:7:in `create'
But in the response I'm getting a huge chunk of HTML. These routes are wrapped in scope :v1, defaults: { format: :json } do
so I would expect the response format to be JSON. Is this expected behavior?
Yes I plan to catch errors and handle them, but I'm confused why a rails API only application would return any html.
Rails 7.0.2.2 Ruby 3.0.3