Just in case anyone stumbles upon this same issue, respond_with tries to build the location HTTP header when responding to a POST (create) action. When you pass an object that is not an ActiveRecord instance (or doesn't respond to #to_model), it will fail. It may also fail occasionally due to naming issues. I believe internally it uses the polymorphic_url or url_for.
To work around this issue, you can pass location: nil for objects that don't have a URL:
respond_with(object, location: nil)
Or, if the URL can't be built automatically, you can help it by passing the right one:
respond_with(object, location: custom_url_for(object))