Skip to content

Commit d8619b5

Browse files
committed
feature/Add basic connect view
1 parent 311a462 commit d8619b5

File tree

8 files changed

+42
-2
lines changed

8 files changed

+42
-2
lines changed

app/assets/stylesheets/helpers.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,9 @@
6464
}
6565
.margin-auto { margin: 0 auto; }
6666

67+
.padding-left { padding-left: 16px; }
68+
.padding-right { padding-right: 16px; }
69+
6770
.text-center { text-align: center; }
6871

6972
// TEXT
@@ -73,6 +76,7 @@
7376
// FONT
7477

7578
.normal { font-weight: normal; }
79+
.light { font-weight: 100; }
7680

7781
// COLOR
7882

app/controllers/application_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def set_toast_message
2323

2424
def assign_users_for_connect
2525
if user_signed_in?
26-
@users_for_connect = User.where.not(id: current_user.following.pluck(:id) << current_user.id).limit(5)
26+
@users_for_connect = current_user.not_following.limit(5)
2727
else
2828
@users_for_connect = User.order(updated_at: :desc).limit(5)
2929
end

app/controllers/home_controller.rb

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
class HomeController < ApplicationController
2+
before_action :authenticate_user!, only: :connect
3+
24
def index
35
@display_popover = true
46

@@ -26,4 +28,24 @@ def index
2628
end
2729
end
2830
end
31+
32+
def connect
33+
@page_title = 'Connect'
34+
@users = current_user.not_following
35+
36+
# @users = current_user.not_following
37+
38+
# @users = @users
39+
# .order(created_at: :desc)
40+
# .paginate(page: params[:page] || 1, per_page: 15)
41+
42+
# respond_to do |format|
43+
# format.json do
44+
# render json: {
45+
# entries: render_to_string(partial: 'snippets/snippets', formats: [:html]),
46+
# pagination: view_context.will_paginate(@users)
47+
# }
48+
# end
49+
# end
50+
end
2951
end

app/models/user.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,13 @@ class User < ApplicationRecord
3838
validates :bio, length: { maximum: 160 }
3939
validates :location, length: { maximum: 30 }
4040

41+
# Spend some time working out how to obtain all users the given user is not following
42+
scope :not_followed_by, -> (user) { where.not(id: user.following.pluck(:id) << user.id) }
43+
44+
def not_following
45+
self.class.not_followed_by(self)
46+
end
47+
4148
def created?(snippet)
4249
snippets.find_by(id: snippet.id).present?
4350
end

app/views/home/connect.html.erb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<% @users.each do |user| %>
2+
<%= render partial: 'users/follow_preview', locals: { user: user } %>
3+
<% end %>

app/views/shared/_sidebar.html.erb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,5 +38,8 @@
3838
<% @users_for_connect.each do |user| %>
3939
<%= render partial: 'users/connect', locals: { user: user } %>
4040
<% end %>
41+
<div class="flex flex-end">
42+
<%= link_to 'More...', connect_path, class: 'padding-right light' %>
43+
</div>
4144
</div>
4245
</div>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
<div class="card--container card--container-padding">
2-
<%= render partial: 'preview', locals: { user: user } %>
2+
<%= render partial: 'users/preview', locals: { user: user } %>
33
<span class="follow--description"><%= user.bio %></span>
44
</div>

config/routes.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
devise_for :users, controllers: { registrations: 'registrations', sessions: 'sessions' }
1010
# For details on the DSL available within this file, see https://guides.rubyonrails.org/routing.html
1111
root to: 'home#index'
12+
get '/connect', to: 'home#connect'
1213

1314
namespace :modals do
1415
resources :users do

0 commit comments

Comments
 (0)