Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community!
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Dario Hunt
2,245 PointsActivity Feed with acts_as_follower instead of Friends
I have this set up in my ActivitiesController:
class ActivitiesController < ApplicationController
def index
following_ids = current_member.following_members.map(&:id)
@activities = Activity.where("member_id in (?)", following_ids.push(current_member.id)).order("created_at desc")
end
end
This set up in my FollowsController:
def create
@member = Member.find_by_user_name(params[:member_id])
@follow_member = current_member.follow(@member)
if @follow_member
current_member.create_activity(@follow_member, 'followed')
respond_to do |format|
format.html { redirect_to @member }
format.js
end
end
end
And this set up to display the activity of following another member:
<div>
<span class="status_name">
<%= link_to activity.member.user_name, profile_path(activity.member) %>
</span>
<span>
is now following <%= link_to activity.targetable.following_member.user_name, "#" %>
</span>
<span class="meta">
<%= time_ago_in_words(activity.targetable.created_at) %>
</span>
</div>
<div class="act_content">
<%= follow_profile_link activity.targetable.following_member %>
</div>
I was able to get the following action to create a new activity item in the feed just fine but I can't figure out how to call to the member who's being followed. I get this error:
undefined method `following_members'
I can't figure out what I need to do or what specifically to call to make this work. Any ideas?

Dario Hunt
2,245 PointsI understand that. But lessons are meant to be examples that you can build off of. Anyways I figured this problem out.

Andre' Jones
26,671 Pointscool i've used some acts_as_etc gems to it makes stuff alot simpler
Andre' Jones
26,671 PointsAndre' Jones
26,671 Pointsgems are cool but I'd stick with the lessons. I dont know what skill level your at, but the things they'll teach you will be more valuable than using gems.