I have a rails app where my users can buddy up with other users. Since that relationship can have a status (approved/rejected/pending), I decided to go with a join model (UserRelationship) so now I have the attribute.

To handle state for that join model, I have a controller (UserRelationshipsController) with actions/RESTful endpoints for changing the state of the relationship. Is this bad practice? If so, where should I handle state-changes for the relationship? In the User model?

  • That's totally ok. Quite typical actually and the only way to stay RESTful, otherwise you would have to add some non-REST actions to the UsersController. Jun 18, 2014 at 16:09
  • You outlined exactly the right approach.
    – Ben Lee
    Jul 3, 2014 at 4:22
  • Yep that's the way to do it
    – Vince V.
    Aug 23, 2015 at 18:20

1 Answer 1


You can treat UserRelationship as a separate resource (as you proposed in your question) or you can use Nested resources (http://guides.rubyonrails.org/routing.html#nested-resources) to have something like this

POST user/9/relationship (POST/PATCH: user_id: 10, status: 'confirmed')

to set/get relationship statuses for specific user.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.