-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: filter users by followed/not followed
fix: reduce min-width horribly ugly on mobile
- Loading branch information
1 parent
ae7ab71
commit 6140f9c
Showing
15 changed files
with
78 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,16 @@ | ||
class UsersController < ApplicationController | ||
def index | ||
@users = User.all.includes(:profile).where.not(id: current_user.id) | ||
@users = User.where.not(id: current_user.id).includes(:profile) | ||
@followed_users = current_user.followed_users.unscope(:includes) | ||
@not_followed_users = @users - @followed_users | ||
|
||
case params[:filter] | ||
when "followed" | ||
@users = @followed_users | ||
when "not followed" | ||
@users = @not_followed_users | ||
else | ||
@users = @users | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
module SimpsonsHelper | ||
def simpsons_name | ||
Faker::TvShows::Simpsons.character | ||
end | ||
|
||
def simpsons_quote | ||
Faker::TvShows::Simpsons.quote | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<div class="new-comment-container"> | ||
<%= form_with model: [@post, Comment.new] do |comment_form| %> | ||
<fieldset> | ||
<legend>Comment on this post | ||
</legend> | ||
<%= comment_form.text_area :body, cols: 40, rows: 12 %> | ||
</fieldset> | ||
<%= comment_form.submit "Comment" %> | ||
<% end %> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
<%# FIXIT: not posting changes %> | ||
<%= form_with(model: request, method: :delete) do |form| %> | ||
<%= form.submit "Unfollow" %> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,11 @@ | ||
<div class="actions-container"> | ||
<%= link_to "Edit Post", edit_post_path(@post) %> | ||
<%= link_to "Delete Post", post_path(@post), data: { "turbo-method": :delete } | ||
<%= link_to "Edit", edit_post_path(@post) %> | ||
<%= link_to "Delete", post_path(@post), data: { "turbo-method": :delete } | ||
%> | ||
<%# check if post is in liked_by scope. yes: like, no: unlike %> | ||
<% if current_user.liked_posts.include?(@post) %> | ||
<%= link_to "Unlike", post_like_path(@post), data: { "turbo-method": :delete } | ||
%> | ||
<% else %> | ||
<%= link_to "Like", post_likes_path(@post), data: { "turbo-method": :post } %> | ||
<% end %> | ||
</div> | ||
<div class="new-comment-container"> | ||
<%= form_with model: [@post, Comment.new] do |comment_form| %> | ||
<fieldset> | ||
<legend>Comment on this post | ||
</legend> | ||
<%= comment_form.text_area :body, cols: 40, rows: 12 %> | ||
<%= comment_form.submit "Comment" %> | ||
<% end %> | ||
</fieldset> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
|
||
<div class="page-header"> | ||
<h2><%= @post.title %></h2> | ||
</div> | ||
<div class="post-container"> | ||
<%= render partial: 'post' %> | ||
<%= render partial: 'actions' %> | ||
<%= render partial: 'comments/form' %> | ||
<%= render partial: 'comments' %> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<%# _search.html.erb %> | ||
<div class="search-container"> | ||
<%= form_with method: :get do |search_form| %> | ||
<legend>Filter by:</legend> | ||
<%= search_form.select :filter, | ||
%w[all followed not\ followed], | ||
{ selected: params[:filter] || "not followed" } %> | ||
<%= search_form.submit "Filter" %> | ||
<% end %> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters