Try specifying the model and url separately:
form_with(model: @activity, url: [@trip, @activity])
According the docs the the values for url
are “Akin to values passed to url_for or link_to” so using an array should work.
This also works with shallow nesting since the array is compacted.