Q:

Controller design for likable/followable objects

I have three models, User, Product, Like. That is, a user can (un)like a product...
I wonder what would be best practice to design controller and models. 

Creating likes_controller and process create/destroy actions 
Creating like/unlike actions inside products_controller 
or something else.

Second question; into which model should I put methods such as "retrieve_likes," "liked?," or "like! /unlike!"
Edit: I found this excellent gem through TeachMeToCode.com, https://github.com/cavneb/make_flaggable

A:

I've done both option 1 and 2 before and they've both worked fine. It really depends on your philosophy and how much of the REST kool-aid you've drank. Go with #1 to be RESTful.  I've found sticking to a more RESTful interface makes testing seem a bit cleaner and the code, in general, seem a bit cleaner. At the expense, however, of having way more files.
As for the models, you could create a Likable module which contains the methods for "liked?", etc...  Then you can include this module in any of the models which need them.  Take a look at some gems that extend ActiveRecord models to get an idea how to do that.

