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

Showing a user is online now

I'm currently building a profile page for an app that I'm working on but I'm not sure of the best way to show if a user is currently online, or if they're not online how long ago it has been since they were last active.

Any tips?

1 Answer

You would have to have a way for the users session timestamp to be stored in a database. For example, every time they click a link on your site, it updates the timestamp with the current time. Then if, after 5 minutes of inactivity, they could be considered offline. Devise stores the last login timestamp, so you already have access to that if you want to say when their last login was.