You will most likely have to store some of these relationships in different database tables. For example, User
has_many :friends
. This design encourages a Friend
model. Which leads to a FriendsController
and to urls like POST /user/1/friend
to create a friendship between the current user (user2) and user 1.
Those belong in a separate controller.
If you need more Ajax actions on a user, defining them in UsersController
is the right place. "Give me your number", "Give me your email" and "View Photos", depending on requirements, could be hidden sections of the html, or simple Ajax GET requests to the UserController
to render partials or JSON.
Those can stay on the UserController
GENERAL ADVICE: Always try to stay within the 7 actions for each controller (new, create, edit, update, index, show, destroy) - when you feel you need to define your own action, think about which of the 7 it is closest to. Can it be combined gracefully? If not, then is it acting on a separate concept?