made settings page responsive and edited route from connections/new to add_contact

This commit is contained in:
Beatrice Olivera
2018-09-02 00:47:41 +01:00
parent 6a1992a29f
commit da9e799436
10 changed files with 110 additions and 62 deletions

View File

@@ -1,6 +1,5 @@
class ConnectionsController < ApplicationController
def new
end
def create
@@ -10,9 +9,17 @@ class ConnectionsController < ApplicationController
@connection.contact = contact_user
if @connection.save
redirect_to contacts_path
contact_message = nil
if contact_user.first_name.nil? || contact_user.last_name.nil?
contact_message = "#{contact_user.email}"
else
contact_message = "#{contact_user.first_name} #{contact_user.last_name}"
end
flash[:notice] = "Added #{contact_message} to contacts"
redirect_to contacts_path
else
flash[:alert] = "Invalid email address!"
render 'new'
end
end
end