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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T00:18:17+00:00 2026-05-15T00:18:17+00:00

I need to model Owners and Rentees in an application, so you have stuff

  • 0

I need to model Owners and Rentees in an application, so you have stuff that is always owned by someone and can be rented for someone else. I first approached this problem with Single Table Inheritance because both types of person will share all attributes, so you would have a model called Person associated to a table people with Owner and Rentee inheriting from Person.

The problem is that Single type inheritance discerns subtypes using a field type and therefore a record in the table can represent either an Owner or a Rentee but not both at the same time, while in the real context you can have an Owner which is renting something from another Owner and therefore that person is at the same time an Owner and a Rentee.

How would you approach this problem? Would you use separated tables for owners and rentees? Is there any other type of table inheritance in Rails?

  • 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-05-15T00:18:18+00:00Added an answer on May 15, 2026 at 12:18 am

    I would suggest that you keep it simple. You have people who can both rent and own items – same people, same items – just add a way to track who owns and item and who rented it.

    You could do something like this:

    class Person
      has_many :items
      has_many :rented_items, :class_name => "Item", :foreign_key => "rentee_id"
    end
    
    class Item
      belongs_to :person
      belongs_to :rentee, :class_name => "Person", :foreign_key => "rentee_id"
    end
    
    # so you have:
    person.items # all the items a person owns
    person.rented_items # all the items he has rented
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a need for a model(?) on my app which basically contains a
I need to figure out a way to set ValidateRequest at model...I understand that
I have a prototype model where I need to include the following extension methods
I have a User and Company model. There are three possible roles that a
I recently got a ForeignKey clash in my Django model. I have the need
In a WPF MVVM application, you have view models that contain all the logic
I need to model-bind data from textboxes generated dynamically on the client side (using
I'm working on a Web service in Django, and I need to model a
I need to load a Model in a component to save the Data of
I need to load a model, existing of +/- 20 tables from the database

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.