Work around Rails bug (rails#5332) for #351.