REST, Nested Routes and Best Practices

Hi everyone,

I am trying to strictly adhere to REST and I have a few code
organization questions.

My database tables are as follows:


The relationships are as follows:

GROUPS have many USERS and USERS have many GROUPS.
EVENTS have many USERS and USERS have many EVENTS.

So, right now, I have a controller for users, groups and events. I got
to the point where I want to have USERS add themselves to a GROUP and/or
an EVENT. Before I add methods to the group or event controller
specifically that are called something like add_user, delete_user,
edit_user ... I want to get everyones take on my problem.

I think you would benefit a Memberships controller (or something like
that), that would handle the adding/removing of users to and from
groups. You might also want a corresponding membership model (though
it's not totally necessary, but many people find it helpful).

That way, your Users and Groups controllers stay "clean", and you
isolate the membership-ness stuff to a separate controller.


Jeff Cohen wrote: