add rails dependency and improve structure