Display followers and following
This commit is contained in:
parent
b17ef5fac7
commit
e4c1739fd9
|
@ -0,0 +1,9 @@
|
||||||
|
class Profiles::FollowersController < ApplicationController
|
||||||
|
before_action :set_profile
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def set_profile
|
||||||
|
@profile = Profile.find params[:profile_id]
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,9 @@
|
||||||
|
class Profiles::FollowingController < ApplicationController
|
||||||
|
before_action :set_profile
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def set_profile
|
||||||
|
@profile = Profile.find params[:profile_id]
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,11 @@
|
||||||
|
<div class="my-4">
|
||||||
|
<strong>❮ <%= link_to @profile.full_name, @profile %></strong>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<% if @profile.following_profiles.present? %>
|
||||||
|
<ul>
|
||||||
|
<% @profile.following_profiles.each do |following_profile| %>
|
||||||
|
<li><%= link_to following_profile.full_name, following_profile %></li>
|
||||||
|
<% end %>
|
||||||
|
</ul>
|
||||||
|
<% end %>
|
|
@ -0,0 +1,11 @@
|
||||||
|
<div class="my-4">
|
||||||
|
<strong>❮ <%= link_to @profile.full_name, @profile %></strong>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<% if @profile.followed_profiles.present? %>
|
||||||
|
<ul>
|
||||||
|
<% @profile.followed_profiles.each do |followed_profile| %>
|
||||||
|
<li><%= link_to followed_profile.full_name, followed_profile %></li>
|
||||||
|
<% end %>
|
||||||
|
</ul>
|
||||||
|
<% end %>
|
|
@ -1,11 +1,11 @@
|
||||||
<h1><%= @profile.full_name %></h1>
|
<h1><%= @profile.full_name %></h1>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
<%= @profile.following_profiles.count %>
|
<%= link_to "#{@profile.following_profiles.count} Followers",
|
||||||
Followers
|
profile_followers_path(@profile) %>
|
||||||
•
|
•
|
||||||
<%= @profile.followed_profiles.count %>
|
<%= link_to "#{@profile.followed_profiles.count} Following",
|
||||||
Following
|
profile_following_index_path(@profile) %>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p><%= @profile.description %></p>
|
<p><%= @profile.description %></p>
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
Rails.application.routes.draw do
|
Rails.application.routes.draw do
|
||||||
root to: 'home#show'
|
root to: 'home#show'
|
||||||
|
|
||||||
resources :profiles, only: %i[index show]
|
resources :profiles, only: %i[index show] do
|
||||||
|
resources :followers, controller: 'profiles/followers', only: :index
|
||||||
|
resources :following, controller: 'profiles/following', only: :index
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Reference in New Issue