Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1061149
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T18:26:06+00:00 2026-05-16T18:26:06+00:00

I have 2 models – User and Activity – which are related by a

  • 0

I have 2 models – User and Activity – which are related by a has_many :through using the UserActivity model. A User can either “want” or “done” an activity, which creates a UserActivity record and sets the appropriate boolean.

What would you recommend for handling these actions when creating routes and controller actions? Would something like activity/:id/want, and activity/:id/done make the most sense, and thus have 2 member routes under the activity resource? Or would it make more sense to just use the update/create actions in the user_activity controller, with posting to /user_activity for a create, and putting to /user_activity/:id to update?

  • 1 1 Answer
  • 1 View
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T18:26:07+00:00Added an answer on May 16, 2026 at 6:26 pm

    I would go with the latter approach, i.e. by allowing POST/PUT access to “user_activity”. In the REST world this is considered as a new resource even though it just forms a relationship between “user” and “activity” resources.

    One thought which comes to mind is to separate “want” or “done” activity types as a new resource as well(e.g. “status”). The idea is clean as it is even without it, but if there is a chance that you will have to extend the list to something on top of “want” or “done” (e.g. “someday/maybe”), it may be easier to define it as a new resource rather now than later.

    So you would have:

    • user resource: /user and /user/id
    • activity resource: /activity and /activity/id
    • status resource: /status and /status/id
    • resource which forms the relationship between user, activity and resource: /user-activity and /user-activity/id

    Depending on your URI design you can then work in accessable URIs which would allow you to get all activities for a user which are in a specific state, e.g.: /user-activity/user/{userId}/status/{statusId}


    Please note: I cannot advise on Ruby-on-Rails specifics (as I’m from the PHP world), but I think that the (REST) principles should be very similar.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have models called User , Activity , and Task and I can do
I have three models: class User include Mongoid::Document field :name, :type => String has_many
I have an extended UserProfile model in django: class UserProfile(models.Model): user = models.ForeignKey(User, unique=True)
I'm using Devise and have models set up like this: User has_one :profile Profile
I have models for eg like this class Model(): time=models.DateTimeField() free=models.BooleanField(default=False) user=models.ForeignKey(User) //it is
I have models User and Message. Every user can send messages to other users.
I have models: class Model < ActiveRecord::Base has_many :model2 end class Model2 < ActiveRecord::Base
I have Users which can be either TypeS , TypeC , or TypeA .
I have models as follows: User has_many goals, Goal has_many tasks, Task has_many day_tasks.
I have models Category and Deal and having has_many :through mapping via categories_deals .

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.