diff --git a/app/controllers/cities_controller.rb b/app/controllers/cities_controller.rb index 4799f8f0..de1ab180 100644 --- a/app/controllers/cities_controller.rb +++ b/app/controllers/cities_controller.rb @@ -1,38 +1,13 @@ class CitiesController < ApplicationController - before_action :set_city, except: [:index, :new, :index, :forbes_new, :forbes_create] + before_action :set_city, except: [:index, :new, :index] before_action :authenticate_user!, :authorized?, only: [:new, :create, :edit, :update, :destroy] - before_action :away_ye_waitlisted, except: [:index, :forbes_show, :forbes_new, :forbes_suggest, :forbes_create, :forbes_set_city] + before_action :away_ye_waitlisted, except: [:index, :forbes_show, :forbes_set_city] # GET /cities def index use_new_styles end - def forbes_new - use_new_styles - if current_user - @city = City.new - else - flash[:notice] = 'Sign up first so we can let you know when your city is approved!' - redirect_to sign_up_path - end - end - - def forbes_create - #NOTE: Seems unnecessary but required for the error case - use_new_styles - - @city = NewSuggestedCity.call(city_params, current_user) - - respond_to do |format| - if @city.persisted? - format.html { redirect_to forbes_city_path(@city), notice: 'We\'ve gotten your submission and will get to it ASAP.' } - else - format.html { render :forbes_new, alert: "Something went wrong! Our fault. Could you try again?" } - end - end - end - def forbes_set_city current_user.update(home_city: @city) redirect_to forbes_city_path(@city) diff --git a/app/controllers/city_suggestions_controller.rb b/app/controllers/city_suggestions_controller.rb new file mode 100644 index 00000000..282c8cc3 --- /dev/null +++ b/app/controllers/city_suggestions_controller.rb @@ -0,0 +1,26 @@ +class CitySuggestionsController < ApplicationController + def new + use_new_styles + if current_user + @city = City.new + else + flash[:notice] = 'Sign up first so we can let you know when your city is approved!' + redirect_to sign_up_path + end + end + + def create + use_new_styles + @city = NewSuggestedCity.call(city_params, current_user) + if @city.persisted? + redirect_to forbes_city_path(@city), notice: 'We\'ve gotten your submission and will get to it ASAP.' + else + render :new, alert: "Something went wrong! Our fault. Could you try again?" + end + end + +private + def city_params + params.require(:city).permit! + end +end \ No newline at end of file diff --git a/app/views/cities/_user_form.html.haml b/app/views/cities/_user_form.html.haml deleted file mode 100644 index b6cccb9e..00000000 --- a/app/views/cities/_user_form.html.haml +++ /dev/null @@ -1,17 +0,0 @@ -.submit-city-container - = form_for @city, html: {class: 'dummy new_city'}, url: suggest_create_cities_path do |f| - = f.text_field :name, placeholder: 'Your city or college name' - = f.submit 'Submit', data: { confirmation: false }, class: 'save-city' - .city-confirmation-text - %h2.confirm-message - Double check your spelling! And make sure it’s just the city or school name. - %p - After you confirm, we’ll make sure everything checks out and email you - when your friends and neighbors can join you for Tea With Strangers. - - if @city.errors.any? - - #error_explanation - %h2= "#{pluralize(@city.errors.count, "error")} prohibited this city from being saved:" - %ul - - @city.errors.full_messages.each do |msg| - %li= msg diff --git a/app/views/cities/forbes_new.html.erb b/app/views/cities/forbes_new.html.erb deleted file mode 100644 index 4eed30f3..00000000 --- a/app/views/cities/forbes_new.html.erb +++ /dev/null @@ -1,24 +0,0 @@ -
If you didn’t find your city in the list before, add it here!
-If you didn’t find your city in the list before, add it here!
++ After you confirm, we’ll make sure everything checks out and email you + when your friends and neighbors can join you for Tea With Strangers. +
+