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

  • SEARCH
  • Home
  • 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 8204279
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T07:50:59+00:00 2026-06-07T07:50:59+00:00

I have 3 models right now, Group, User and Asset. How should I model

  • 0

I have 3 models right now, Group, User and Asset.

How should I model it such that

  1. User belongs to Group, Group has many users
  2. Asset belongs to Group, Group has many asset
  3. Every User in the Group have access to the asset, for example @user.assets will fetch assets’ info

Thanks.

  • 1 1 Answer
  • 0 Views
  • 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-06-07T07:51:00+00:00Added an answer on June 7, 2026 at 7:51 am

    There’s no need for anything fancy. Basic rails associations between the models will take care of everything.

    To have a user access the group’s assets, I’d recommend using delegate.

    For more info on delegate check the Rails Guide: Active Support Core Extensions

    class Group < ActiveRecord::Base
      has_many :users
      has_many :assets 
    end
    
    class Asset < ActiveRecord::Base
      belongs_to :group
    end
    
    class User < ActiveRecord::Base
      belongs_to :group
      delegate :assets, :to => :group
    end
    

    Using delegate allows you to access assets using @user.assets as you asked.

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

Sidebar

Related Questions

Right now, I have more than 25 vertices that form a model. I want
Right now, I have three models Post, Comment and User (using Devise ) associated
Say we have two aggregate roots in a domain model: Group and User. Now,
I have that situation: I have models Item, Region and Country. class Item(models.Model): name
I have an existing site that has a bunch of different models and controllers.
In have 3 models here: projects threads (project_id) thread_participations (thread_id, read boolean) Right now
I'm defining my Django models right now and I realized that there wasn't a
I have two tables, users and groups . A user can belong to many
Right now I have: @models = ActiveRecord::Base.send(:subclasses) But I get this in the log:
I have models like this: class Vendor(models.Model): title = models.CharField() class Product(models.Model): ... vendor

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.