Refactored rails/routes.rb to avoid repeated code