Questions tagged [model-associations]

Models can associate in three main ways: one to many, one to one, and many to many.

This is tagged primarily in Ruby community. Models can associate in three main ways: one to many, one to one, and many to many.

865 questions
-1
votes
2 answers

Multiple Model Associations to same table

My situation: I want to bring a HABTM and a hasOne relation working in the same model. unfortunatelly its not loading the groupleaders userinformation into the usergroups. a user can have multiple usergroups a usergroup can have one groupleader…
endo.anaconda
  • 2,449
  • 4
  • 29
  • 55
-1
votes
2 answers

Cakephp inheritance of model associations

If I create a Model Car with some associations: hasOne Driver hasMany Wheel And then create a Model Truck extending Car with class Truck extends Car { ... } is it normal that the associations from Car are not inherited from Truck? What are the…
Martin Cup
  • 2,399
  • 1
  • 21
  • 32
-1
votes
1 answer

What is the difference between :include and :through options in rails associations?

I don't understand in which case I should use the :include option instead of the :through option ? For instance I can write my models like this : Class Customer < ActiveRecord::Base has_many :orders, :include => :line_items end class Order <…
Douglas
  • 5,229
  • 3
  • 43
  • 54
-2
votes
1 answer

Ruby on rails active record associations

I need 2 models for my store: Shoe ShoeSize According to my concept - one shoe can have several sizes (one model of shoes can be 34,35,36,37 size). What types of associations should I use? What database table fileds do I need to create to support…
prosto.vint
  • 1,403
  • 2
  • 17
  • 30
-2
votes
1 answer

many-to-many relationship in rails

I have the following models class Order < ApplicationRecord has_many :order_details has_many :products, through: :order_details end class OrderDetail < ApplicationRecord belongs_to :order belongs_to :product end class Product <…
gaacode
  • 7
  • 2
-2
votes
3 answers

OneToOne Association In JPA not working using Spring boot and spring data JPA

I am trying to implement the OneToOne association in JPA and trying to join two tables using spring boot and spring data JPA. I created one spring boot microservice and implemented the one to one association in my model. But when I am running code I…
Mr.DevEng
  • 2,651
  • 14
  • 57
  • 115
-2
votes
1 answer

trying the rails model association

I'm not sure if this a best practices in terms of association. Anyone can help me //post,rb class Post < ApplicationRecord belongs_to :user has_one :location, through: :user has_one :category, through: :user has_one :type, through:…
Eric Luciano
  • 35
  • 1
  • 9
-2
votes
2 answers

How to implement the class - Student relationship in c#?

I want to implement a system, which represents a ClassRoom- Student relationship. I want to impose the constraint that Each ClassRoom can have any number of students, but one student can be at only one ClassRoom. I have created two classes -…
-3
votes
2 answers

R: How to determine which variables are associated with a missing data field

I have a dataset that I am trying to understand why one specific variable (Var1) has blank values. I have two questions, and I use R (and am a novice coder): Var1 is 60% complete (field in entered with alphnumeric values, but 40% of entries are…
Ryan S
  • 35
  • 1
  • 3
-3
votes
2 answers

Ruby on Rails Model Associations, user admin and listing

I feel like this is a really easy question but i've been stuck for a while. I have three models, user, listing and admin. Please how do i make both user and listing belong to admin?
1 2 3
57
58