Smart redirecting url to another for Ruby on Rails