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


Jamie Barton
Jamie Barton
14,498 Points

Vote up/down like on Treehouse forums

Hi guys

Quite new to Rails and I would love to implement a similar feature to my website for voting up and down content.

What I think would be better is a star, which when clicks replaces the empty star with a one which is perhaps filled, is that makes sense, or shows another class.

Anyways, when it is clicked again it would then do the reverse.

Would I use a format.js response to output some rendered javascript which outputs the new button and vise versa?

Thanks for any tips!

1 Answer

Brandon Barrette
Brandon Barrette
20,485 Points

I would check out acts_as_votable gem, because you will need to store the users votes. Then use javascript to fill in the star (or replace the image) or vice-versa on click.