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 8964987
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T16:42:48+00:00 2026-06-15T16:42:48+00:00

This question comes from breaking up a question that was too big. Users create

  • 0

This question comes from breaking up a question that was too big.

Users create Events as a Role in a Network. The Events are then connected to both the Role (different Users can occupy that Role when they are hired or fired) as well as the Event. Users that have administrative Roles can access all Events regardless of the Role that created the Event.

It is possible that Role could be destroyed, but the Event will persist as long as the Network exists. (Like if a position is deleted, but they still want the data for retired positions.)

So can the Event both belongs_to a Role and a Network separately? Is that bad rails design? Is there another way to do this? Would I have a special “Retired” role and keep events always tied to a Role and then use belongs_to :network, :through => :role?

Network.rb

class Network < ActiveRecord::Base
  has_many :roles
  has_many :users, :through => :roles
  has_many :events
end

Role.rb

class Role < ActiveRecord::Base
  belongs_to :user
  belongs_to :network
end

Event.rb – Is this right?

class Event < ActiveRecord::Base
  belongs_to :role  
  belongs to :network
end
  • 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-15T16:42:49+00:00Added an answer on June 15, 2026 at 4:42 pm

    In my opinion it’s not bad design with your associations (Events belonging to both Role and Network). And I think it’s more confusing to have a “retired Role” than have it NULL. But perhaps you should consider having a column status on the Role rather than deleting it. If the status is not e.g. 1 (if 1 = ok and 2 = inactive as an example) it can’t be used anymore, acting as it was deleted.

    It’s difficult to give an advice when you don’t have the whole picture, but, as I said, in my opinion it’s no need for a “retired” Role just to be able to change the associations.

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

Sidebar

Related Questions

This question comes from a need to ensure that changes I've made to code
This question comes from a range of other questions that all deal with essentially
This question comes from the problem of another question of mine. In that question,
OK! First of all this question comes from a man who digs too deep
This question comes from a discussion that was touched off on this other question:
Check this example before reading the question - http://www.sqlfiddle.com/#!2/fcf3e/8 The following data comes from
This question comes to you from someone who's been burned by SVN before and
This question comes from a code analysis run against an object I've created. The
This question comes from: C++11 thread doesn't work with virtual member function As suggested
This question comes from my experience with the following question: https://stackoverflow.com/questions/492748/new-responses-icon-on-so-crashes-ie7-closed In that question,

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.