Commit 1de09ff3 authored by Vanessa Silva's avatar Vanessa Silva
Browse files

Methods fixed

parent b41e76b5
Pipeline #41753 failed with stage
in 2 minutes and 36 seconds
......@@ -4,7 +4,7 @@ class LikesController < ApplicationController
if @like.save
flash[:notice] = 'Like successful'
matches_create
create_match if likes_mutually
redirect_to root_path
else
......@@ -16,10 +16,15 @@ class LikesController < ApplicationController
private
def matches_create
user = User.find_by(id: like_params[:liked_user_id])
def create_match
Match.create(user_one: @got_liked_user, user_two: current_user)
end
def likes_mutually
@got_liked_user = User.find_by(id: like_params[:liked_user_id])
Match.create(user_one_id: like_params[:user_id], user_two_id: like_params[:liked_user_id]) if user.liked_users.include?(current_user)
true if @got_liked_user.liked_users.include?(current_user)
end
def like_params
......
......@@ -2,12 +2,12 @@
<% if user_signed_in? %>
<div class="grid-container">
<div class="page-division items-center">
<% if @match_users.nil? %>
<% if @match_users.empty? %>
<div>
<h1>No matches yet!</h1>
<p>No matches yet!</p>
</div>
<% else %>
<h1>Matches</h1>
<p>Matches</p>
<% @match_users.each do |user| %>
<div>
<% if user.profile_picture.attached? %>
......@@ -27,7 +27,7 @@
<% end %>
</div>
<div class="items-center">
<h1>Nope! Like!</h1>
<p>Swipe!</p>
<% if @possible_match.nil? %>
<div>
<h1>No more people to see, sorry!</h1>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment