Rasmus Styrk
Rasmus Styrk

Reputation: 1346

Where should I put methods to get a groups users?

I have a group controller that manages groups, each group can have many users.

I want to retrieve the users using JSON but where should I put the logic and in what controller?

It's more a matter of what feels good, any suggestions?

Should I use something like /groups/1/users or /users/group/1?

Upvotes: 0

Views: 36

Answers (2)

MurifoX
MurifoX

Reputation: 15089

I believe there are two approaches to the problem. The RESTFUL one: /groups/1/users, and the other would be passing params to the users resource via GET: /users?group=1

Upvotes: 0

a.s.t.r.o
a.s.t.r.o

Reputation: 3338

/groups/1/users is the Rails way to go, especially if you use nested resources (the logic for users goes into UsersController naturally).

Upvotes: 1

Related Questions