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! While you're at it, check out some resources Treehouse students have shared here.
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 trialUnsubscribed User
60 PointsHow to add "accept follow" or "decline follow" to this app?
Let's say till we developed programming for follow button and start follow. But what if there would accept and decline "follow": Example: "User A" clicks on follow button on "User B", Now "User B" should get an notification that "accept or decline 'User A' ": If "User B" declines "User A", "User A" cannot follow "User B" & vice versa for accept too.
Thanks for showing such intense tutorial, but need these feature as it's common on social network which you must maintain.
2 Answers
Chris Freeman
Treehouse Moderator 68,441 PointsAs to your request as to how to create an accept or decline approval of follow request, the information in the video can be extrapolated to create it. One organization is discussed below. As you read down the new elements, you can see that the details get finer and finer. It's up to you how far to go. The list may not be exhaustive, but does cover the major elements.
- Add a new model called
FollowRequest
that models the request to form aRelationship
. With similarfrom_user
andto_user
attributes. Plus adeclined
attribute, initiallyFalse
- Add new function
request_to_follow
that creates newFollowRequest
instance. This function is triggured by the follow button - Add search to a user's home view that displays any
FollowRequest.to_user
matching their User. If present, display appropriate approve and decline buttons for eachFollowRequest
- Add search to a user's home view that displays any
FollowRequest.from_user
matching their User. These are requests they have made to follow. Ifdeclined
isFalse
then display waiting approval. Ifdeclined
isTrue
then display declined. - The approve button calls the existing
follow
function. - Add new function
decline_to_follow
that changes the valueFollowRequest.declined
toTrue
. - The decline button calls
decline_to_follow
- If
FollowRequest.declined
isTrue
, disable the follow button display - If declined follow requests cause the reverse request to be disabled, create new
FollowRequest
instance with thefrom_user
andto_user
reversed anddeclined
initiated toTrue
As you can see from the above list, As each feature or branch is added to the relationships between users, the amount of overhead and functionality can grown quite rapidly. This is why the course didn't delve into this extra details. There are no new programming techniques needed in the above list, but rather an exercise in planning out the architectural changes.
I hoped this helped. Post back if you need more help. Good luck!!
Unsubscribed User
60 PointsThis would be really helpful to me. Thanks alot, Cris Freeman! That's why "TreeHouse team" rocks! One thing is that your 'TREEHOUSE' User Interface is awesome - it's so simple & perfect.
Chris Freeman
Treehouse Moderator 68,441 PointsChris Freeman
Treehouse Moderator 68,441 PointsMarked as course feedback.