Rewrite as a rails app