Conditional Rails check added so it can be used outside of Rails

Conditional Rails check added so it can be used outside of Rails