Fix Rails 4 detection

This fixes #3019.