Fix rails detection