Check if the `request` variable isn't nil when calling render_to_string

closes #14125
Merge pull request #14129 from joankaradimov/fix-render-to-string

Fix `render_to_string` when called via manually instantiated controllers
Revert "context in validation goes through has many relationship"

This reverts commit 5e3d466d52fa4e9a42c3a1f8773a7c31da875e48.
adding a test for #14106