Skip to content

Commit

Permalink
fixed_views
Browse files Browse the repository at this point in the history
  • Loading branch information
usernaimandrey committed Aug 10, 2022
1 parent 8d2bc48 commit 931b1b4
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 16 deletions.
2 changes: 1 addition & 1 deletion app/controllers/web/home_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
module Web
class HomeController < ApplicationController
def index
@posts = Post.all.order(created_at: :desc)
@posts = Post.includes(:creator).order(created_at: :desc)
end
end
end
6 changes: 3 additions & 3 deletions app/views/web/posts/comments/_show.html.slim
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.mb-3.mt-3
- comments.arrange.each do |comment, _sub_item|
- comments.each do |comment, child_comments|
.card.mb-2
.card-body
.card-text
Expand All @@ -8,10 +8,10 @@
= render partial: 'web/shared/creation_data', locals: { email: comment.user.email, created_at: comment.created_at }

-if comment.has_children?
= render partial: 'web/posts/comments/show', locals: { comments: comment.children }
= render partial: 'web/posts/comments/show', locals: { comments: child_comments, current_comment: current_comment, post: post }
div
- if user_signed_in?
a.text-decoration-none[data-bs-toggle="collapse" href="#collapse-#{comment.id}" role="button" aria-expanded="false"] = t('.reply')
.collapse[id="collapse-#{comment.id}"]
.mb-2.m-4
= render partial: 'web/posts/comments/form', locals: { comment: @comment, parent_id: comment.id, url: post_comments_path(@post, @comment) }
= render partial: 'web/posts/comments/form', locals: { comment: current_comment, parent_id: comment.id, url: post_comments_path(post, current_comment) }
18 changes: 8 additions & 10 deletions app/views/web/posts/likes/_links.html.slim
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
- if like.present?
.d-flex
.mx-2 = @post.likes_count || 0
= link_to(post_like_path(@post, like, anchor: 'likes-section'), rel: :nofollow, method: :delete, class: 'text-dark') do
i.fa-solid.fa-thumbs-up
- else
.d-flex
.mx-2 = @post.likes_count || 0
= link_to(post_likes_path(@post, anchor: 'likes-section'), rel: :nofollow, method: :post, class: 'text-dark') do
i.fa-regular.fa-thumbs-up
.d-flex
.mx-2 = post.likes_count || 0
- if like.present?
= link_to(post_like_path(post, like, anchor: 'likes-section'), rel: :nofollow, method: :delete, class: 'text-dark') do
i.fa-solid.fa-thumbs-up
- else
= link_to(post_likes_path(post, anchor: 'likes-section'), rel: :nofollow, method: :post, class: 'text-dark') do
i.fa-regular.fa-thumbs-up
4 changes: 2 additions & 2 deletions app/views/web/posts/show.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ p
.d-flex.justify-content-between
= render partial: 'web/shared/creation_data', locals: { email: @post.creator.email, created_at: @post.created_at }

= render partial: 'web/posts/likes/links', locals: { like: @like_current_user }
= render partial: 'web/posts/likes/links', locals: { like: @like_current_user, post: @post }

- if user_signed_in?
h3
| #{t('.title')}
= render partial: 'web/posts/comments/form', locals: { comment: @comment, parent_id: nil, url: post_comments_path(@post, @comment) }

= render partial: 'web/posts/comments/show', locals: { comments: @comments }
= render partial: 'web/posts/comments/show', locals: { comments: @comments.arrange, current_comment: @comment, post: @post }

0 comments on commit 931b1b4

Please sign in to comment.