-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Milestone 6: views #6
Merged
Merged
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
87d1122
Feat: Update PostsController#index to fetch user's posts
ITurres 1949ee3
Feat: Update 'UsersController' '#index' and '#show' actions
ITurres b13a81b
Feat: Add meta tags and Bootstrap cdn to 'application.html.erb'
ITurres 1c08e7f
Add '_user_card.html.erb' shared partial
ITurres 02c2338
Feat: Update 'User' 'index' and 'show' views
ITurres 9b96ee1
RStyles: Remove inline flexbox from 'index.html.erb' -main-element-
ITurres abeaed0
Feat: Update inline styles and partials data on 'user#show' page
ITurres e05366d
Styles: update flexbox and card styles on 'user_card' partial
ITurres bdb3fef
Add posts '_posts.html.erb' partial
ITurres e9a5789
Chore: Add 'faker' gem to development
ITurres 7f0c914
Refactor: conditional on comments at 'posts' partial
ITurres 966aab3
Feat: Add button partial to 'user#show' page
ITurres 2353699
Refactor: 'PostsController#index' to Filter Posts by User
ITurres 667988e
Add 'button_link' shared partial
ITurres 46faccc
Feat: update 'posts#index' view
ITurres b435738
Refactor: change 'truncate_n' partial local value at 'posts#index' view
ITurres 3788af3
Feat: update 'PostsController#show' to Filter single Post by User
ITurres 56372c5
Feat: Update 'posts' partial to handle single post and comments
ITurres fc41ae3
Feat: update 'posts#show' view
ITurres 81534de
Docs: Update 'README.md' check complete another future-feature
ITurres d8e3719
Docs: Update 'README.md' tech-stack section
ITurres 5d42e21
Docs: Update 'README.md' by adding key-features section
ITurres File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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,16 @@ | ||
class PostsController < ApplicationController | ||
def index | ||
p '------PostsController------' | ||
if params[:user_id] | ||
@user = User.find(params[:user_id]) | ||
@posts = @user.posts | ||
else | ||
@posts = Post.all | ||
end | ||
end | ||
|
||
def show | ||
p '------PostsController / show------' | ||
@post = Post.find(params[:id]) | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,11 @@ | ||
class UsersController < ApplicationController | ||
def index | ||
p '------UsersController------' | ||
@users = User.all | ||
end | ||
|
||
def show | ||
p '------UsersController / show------' | ||
@user = User.find(params[:id]) | ||
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,45 @@ | ||
<% posts.each_with_index do |post, index| %> | ||
<div class="card mt-3"> | ||
|
||
<%= link_to user_post_path(post.author, post), class: "text-decoration-none text-secondary" do %> | ||
<div class="card-header d-flex justify-content-between"> | ||
<span class="text-success"> | ||
<strong> | ||
Post #<%= index + 1 %> | ||
<%= posts.size == 1 ? " | By #{post.author.name}" : "" %> | ||
</strong> | ||
</span> | ||
<% if posts.size == 1 %> | ||
<div class="text-muted"> | ||
<span>Comments: <%= post.comments_counter %></span>, | ||
<span>Likes: <%= post.likes_counter %></span> | ||
</div> | ||
<% end %> | ||
</div> | ||
|
||
<div class="card-body"> | ||
<h5 class="card-title"><%= post.title %></h5> | ||
<p class="card-text"><%= truncate_n.nil? ? post.text : post.text.truncate(truncate_n) %></p> | ||
</div> | ||
|
||
<% if posts.size > 1 %> | ||
<div class="text-muted pt-1 pb-2 pr-3" style="text-align: end;"> | ||
<span>Comments: <%= post.comments_counter %></span>, | ||
<span>Likes: <%= post.likes_counter %></span> | ||
</div> | ||
<% end %> | ||
<% end %> | ||
</div> | ||
|
||
<% if limit_n > 0 %> | ||
<div class="card card-body mt-1 p-3"> | ||
<ul class="list-unstyled"> | ||
|
||
<% post.most_recent_comments(limit_n).each do |comment| %> | ||
<li><%= comment.author.name %>: <%= comment.text %></li> | ||
<% end %> | ||
|
||
</ul> | ||
</div> | ||
<% 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,20 @@ | ||
<h1>posts/index</h1> | ||
<h1 hidden>posts/index</h1> | ||
|
||
<main class='container mt-4' style="max-width: 900px;"> | ||
<%= render "shared/user_card", user: @user %> | ||
|
||
<div class="mt-4"> | ||
<% if @user.posts.any? %> | ||
<%= render "posts", | ||
posts: @user.most_recent_posts, | ||
truncate_n: 50, | ||
limit_n: 5 %> | ||
<% else %> | ||
<p class="text-muted text-center">No posts yet.</p> | ||
<% end %> | ||
</div> | ||
|
||
<%= render "shared/button_link", | ||
button_text: "Pagination", | ||
path: user_path(@user) %> | ||
<main> |
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 +1,8 @@ | ||
<h1>posts/show</h1> | ||
<h1 hidden>posts/show</h1> | ||
|
||
<main class='container mt-4' style="max-width: 900px;"> | ||
<%= render "posts", | ||
posts: [@post], # ! @post is a single post so we need to wrap it in an array for it to be iterable. | ||
truncate_n: nil, | ||
limit_n: @post.comments_counter %> | ||
</main> |
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,3 @@ | ||
<div class="p-4 text-center"> | ||
<%= link_to button_text, path, class: "btn btn-success" %> | ||
</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,14 @@ | ||
<%= link_to user_path(user), class: "text-decoration-none" do %> | ||
<div class='d-flex justify-content-center mb-3' style='width: auto; margin: 0 auto;'> | ||
<img src=<%= user.photo %> class='card-img-top mr-3 border border-success' | ||
alt='user profile image' | ||
style='width: auto' | ||
/> | ||
<div class='card' style='width: 100%; max-width: 700px;'> | ||
<div class='card-body d-flex justify-content-between'> | ||
<h5 class='card-title mb-0'><%= user.name.capitalize %></h5> | ||
<span class='mb-0 text-muted align-self-start'><%= user.posts_counter %> posts.</span> | ||
</div> | ||
</div> | ||
</div> | ||
<% 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 +1,7 @@ | ||
<h1>users/index</h1> | ||
<h1 hidden>users/index</h1> | ||
|
||
<main class='container mt-4'> | ||
<% @users.each do |user| %> | ||
<%= render "shared/user_card", user: user %> | ||
<% end %> | ||
</main> |
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 +1,29 @@ | ||
<h1>users/show</h1> | ||
<h1 hidden>users/show</h1> | ||
|
||
<main class="container mt-4" style="max-width: 900px;"> | ||
<%= render "shared/user_card", user: @user %> | ||
|
||
<section> | ||
<div class="border border-primary p-3"> | ||
<h2>Bio</h2> | ||
<p><%= @user.bio %></p> | ||
</div> | ||
</section> | ||
|
||
<section> | ||
<div class="mt-4"> | ||
<% if @user.posts.any? %> | ||
<%= render "posts/posts", | ||
posts: @user.most_recent_posts, | ||
truncate_n: 100, | ||
limit_n: 0 %> | ||
<% else %> | ||
<p class="text-muted text-center">No posts yet.</p> | ||
<% end %> | ||
</div> | ||
|
||
<%= render "shared/button_link", | ||
button_text: "See all posts", | ||
path: user_posts_path(@user) %> | ||
</section> | ||
</main> |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @Olamarx! it is running well on my end! 🎯
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It runs well on my end too, just the comments were not added.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Olamarx, a short screencast
addind-data-to-blog-db-dev.webm
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Olamarx, the reason for the issue is that when instantiating the
Comment
model, it expectsauthor
as a parameter. However, in your instantiations, you're sendinguser
instead ofauthor
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i.e