You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Conflicting type and usage for useForm->errors #177
But tbh, I still want to serialize errors before sending to the frontend, so in the starter kit I go with the flow and define a controller helper that turns arrays into strings:
redirect_tosign_up_path,inertia: inertia_errors(@user)# to me this doesn't look better tbh:redirect_tosign_up_path,inertia: {errors: @user.errors.to_hash(true)}# or even this:redirect_tosign_up_path,inertia: {errors: @user.errors}
I like the path to match what the JS side expects. What if we added a slightly modified inertia_errors method to Inertia Rails:
definertia_errors(model,full_messages: true)model.errors.to_hash(full_messages).transform_values(&:to_sentence)end# in the controllerredirect_tosign_up_path,inertia: {errors: inertia_errors(@user)}
If we wanted to be fancy we could (optionally, via the configuration) automatically transform an errors prop to a string (if it's an ActiveRecord object) inside the renderer.
Activity
pricci1 commentedon Mar 9, 2025
Maybe in Laravel it is a
string?Anyways, I added this patch for now
skryukov commentedon Apr 11, 2025
Another option is to define a global re-export:
But tbh, I still want to serialize errors before sending to the frontend, so in the starter kit I go with the flow and define a controller helper that turns arrays into strings:
then I just call it on redirects:
bknoles commentedon Apr 12, 2025
I like the path to match what the JS side expects. What if we added a slightly modified
inertia_errorsmethod to Inertia Rails:If we wanted to be fancy we could (optionally, via the configuration) automatically transform an
errorsprop to a string (if it's an ActiveRecord object) inside the renderer.skryukov commentedon Nov 23, 2025
Inertia now provides a way to define type of error messages by declaring
InertiaConfig.errorValueType, see example here: https://github.com/inertiajs/inertia-rails/blob/master/lib/generators/inertia/install/templates/react/types/globals.d.ts#L6