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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T20:42:16+00:00 2026-06-14T20:42:16+00:00

I am working on a medical application. In it, I have associations between users

  • 0

I am working on a medical application. In it, I have associations between users and clients (obviously), and an association between users and treatments, and users and settings (for a settings table).

But the tricky part here is that the client also has to be associated to the treatments table, because they are the ones that have the treatments on their record. The user is simply the one administrating all of the above. And also we have patients who are associated to clients, so it will need to be multi-layered. So owners have clients who also have patients. And patients have treatments as do Clients and do owners.

It seems really complex to me and I am having a hard time getting anything beyond user working. I am using the basic relationship setup in Rails (i know very little about rails). I am using @treatment.user = current_user on the create method, and then simply associating the tables needed with a user_id. I put a client_id on the treatment table, but that won’t work will it?

Do I need a polymorphic association (not sure what that is though)? OR do I need seperate tables to do all of this matching?

Thanks.

Code:

class User < ActiveRecord::Base
# Include default devise modules.  Others available are:   
# :token_authenticatable, :confirmable,   
# :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
       :recoverable, :rememberable, :trackable, :validatable

# Setup accessible (or protected) attributes for your model  
attr_accessible :email, :password, :password_confirmation,
                :remember_me, :role

  validates :email, presence: true
  has_many :clients
  has_many :settings
  has_many :treatments

  ROLES = %w[admin receptionist practitioner]

  def role_symbols
    [role.to_sym]
  end

  def to_s
    email
  end

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-14T20:42:17+00:00Added an answer on June 14, 2026 at 8:42 pm

    I am not totally sure yet, on what your problem is.
    But since you mentioned you are not familiar with Rails, this might help you:

    Have a look at the has_many :through relation (also available as has_one :through)

    So you could probably do something like this:

    # patient.rb
    class Patient < ActiveRecord::Base
      has_many :treatments, :through => :client
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working on an application for one of our departments that contains medical data.
I have a medical app for the iPhone that I'm working on, where a
I am working on a web-based medical application and need to create a small
I'm working on a stereoscopy application in C++ and OpenGL (for medical image visualization).
I have a database which has a table that stores medical conditions and another
Working with Reporting Services 2008 r2. So here's my issue: We have 5 reports
Working sample using one Table SELECT t.* FROM ( SELECT TITLE.name, (TITLE.value-TITLE.msp) AS Lower,
Working example: http://alpha.jsfiddle.net/gTpWv/ Both of the methods work separately, but once regexp for smilies
I've got a question regarding C#. I am currently working on a medical software
I have started using data.table. Indeed it is very fast and quite nice syntax.

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.