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 trial

Ruby Building Social Features in Ruby on Rails Adding State What is a State Machine?

alex morrison
alex morrison
135 Points

Following/Follower model

Does anyone have any ideas on how to implement states with the follower/following model; in particular, Michael Hartl's implementation of follower/following?

I am new to rails but something like user has_many :followers and followees then a mater of creating the rules on what to disply to followers

3 Answers

Mark Lavelle
Mark Lavelle
2,910 Points

Not sure if i'm right here but I think If you go back over the videos you can see the point where Jason says the model we have is akin to follower / followed. He then introduces the state machine to determine the ability to accept or block friend requests. With the follower / followed model, the user has no control of who follows them, a state machine allows you to control who follows / friends you. I am trying to finish this tutorial using rails 4 and then add it to the Hartl app, Let me know how you get on if you attempt it.

I have found a couple of resources very helpful the last few days and would recommend them to everybody before starting the rails courses on this site. Just to get a better understanding of what is going on.

First is Why's Poignant Guide to Ruby very quirky but the underpinning code is simple to follow and understand.

Then Demo App complete written walk through explaining everything that is happening, which is unfortunately missing from the tutorials on here, but I do respect that the videos would be too long is they went into too much detail.

I think my point is that these videos should only be undertaken once you have an understanding of a Rails application and what exactly everything does.

Good Luck

alex morrison
alex morrison
135 Points

Thanks guys. I've been able to make it work partially in php. I enjoy coding with Ruby on Rails. But I find more implementations of features (particularity, social) with php. I'll keep trying in rails and I will post it when/if I figure it out.