diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 152d41599..ae3ce3692 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -68,8 +68,7 @@ class UsersController < ApplicationController end def load_follows - @followable_types = @user.follows.pluck(:followable_type).uniq - @follows = @user.follows + @follows = @user.follows.group_by(&:followable_type) end def valid_access? diff --git a/app/helpers/follows_helper.rb b/app/helpers/follows_helper.rb index b04835b95..2b09ccb67 100644 --- a/app/helpers/follows_helper.rb +++ b/app/helpers/follows_helper.rb @@ -62,8 +62,16 @@ module FollowsHelper }.invert[entity] end - def entity_partial(class_name) - class_name.parameterize.gsub('-','_') + def entity_class_name(followable) + followable.class.to_s.parameterize.gsub('-','_') + end + + def render_follow(follow) + followable = follow.followable + partial = entity_class_name(followable) + locals = {entity_class_name(followable).to_sym => followable} + + render partial, locals end private diff --git a/app/views/users/_following.html.erb b/app/views/users/_following.html.erb index 110d012aa..83729c2f4 100644 --- a/app/views/users/_following.html.erb +++ b/app/views/users/_following.html.erb @@ -1,6 +1,6 @@