From 3a18d741c2a1f7c69c08cb51221e6a3f65764aba Mon Sep 17 00:00:00 2001 From: "Jesse C. Fisher" Date: Wed, 15 Nov 2023 16:23:23 +0000 Subject: [PATCH] Quickfix micropost feed and policy --- app/models/user.rb | 2 +- app/policies/micropost_policy.rb | 4 ++-- app/views/profiles/index.html.haml | 2 ++ 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/app/models/user.rb b/app/models/user.rb index 84164b14..5656978d 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -122,7 +122,7 @@ class User < ActiveRecord::Base end def feed - Micropost.where("user_id = ?", id) + microposts end end diff --git a/app/policies/micropost_policy.rb b/app/policies/micropost_policy.rb index 34e9239a..e6e3ca2b 100644 --- a/app/policies/micropost_policy.rb +++ b/app/policies/micropost_policy.rb @@ -46,10 +46,10 @@ class MicropostPolicy end def update? - @user.admin? || @user == @micropost.user + @user.admin? || @user == @micropost.micropostable end def destroy? - @user.admin? || @user == @micropost.user + @user.admin? || @user == @micropost.micropostable end end diff --git a/app/views/profiles/index.html.haml b/app/views/profiles/index.html.haml index 18dedfc0..1bdaa43f 100644 --- a/app/views/profiles/index.html.haml +++ b/app/views/profiles/index.html.haml @@ -18,6 +18,8 @@ = social_link.to_icon.html_safe %p= profile.about %span #{profile.followers.count} Followers +    + %span #{profile.microposts.count} Posts - if policy(profile).destroy? = link_to 'Edit', edit_profile_path(profile) = link_to 'Delete', profile, method: :delete, data: { confirm: 'Are you sure?' }