2018-08-31 14:06:42 +00:00
|
|
|
class ConnectionsController < ApplicationController
|
|
|
|
def new
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
def create
|
|
|
|
@connection = Connection.new
|
|
|
|
@connection.user = current_user
|
|
|
|
contact_user = User.find_by(email: params[:user][:email])
|
|
|
|
@connection.contact = contact_user
|
|
|
|
|
|
|
|
if @connection.save
|
|
|
|
redirect_to contacts_path
|
|
|
|
else
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
2018-09-03 13:10:45 +00:00
|
|
|
|
|
|
|
def destroy
|
|
|
|
connection = current_user.connections.find_by(contact_id: params[:id].to_i)
|
|
|
|
connection.destroy
|
|
|
|
redirect_to root_path
|
|
|
|
end
|
2018-08-31 14:06:42 +00:00
|
|
|
end
|