Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Vanessa Silva
Tinder
Commits
1de09ff3
Commit
1de09ff3
authored
Sep 16, 2021
by
Vanessa Silva
Browse files
Methods fixed
parent
b41e76b5
Pipeline
#41753
failed with stage
in 2 minutes and 36 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
8 deletions
+13
-8
app/controllers/likes_controller.rb
app/controllers/likes_controller.rb
+9
-4
app/views/home/index.html.erb
app/views/home/index.html.erb
+4
-4
No files found.
app/controllers/likes_controller.rb
View file @
1de09ff3
...
...
@@ -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
...
...
app/views/home/index.html.erb
View file @
1de09ff3
...
...
@@ -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>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment