Questions tagged [relationships]

Relationships refer to mappings between elements of one set to another set, such as one-to-one, one-to-many, many-to-many.

Relationships can be implicit or explicit depending upon the data model.

Types of relationships

References

832 questions
0
votes
1 answer

symfony2 entity oneToMany and methods

Hi i had fully successfully setted my entity onetoMany and ManyToOne i generated setters and getters and in user entity it created this method: user entity: /** * @ORM\OneToMany(targetEntity="TB\RequestsBundle\Entity\Requests",…
Lukas Lukac
  • 7,766
  • 10
  • 65
  • 75
0
votes
1 answer

Multiple lithium models relationships

I´m actually on a project and working with lithium framework for PHP. I´m using multiple databases (MongoDB and MySQL) and on the MySQL database I have lots of many to many relations between my tables. I´ve been reading about lithium relationships…
0
votes
1 answer

Can a single model "belong_to" more than one parent model?

Just as on StackOverflow, in my app a User can write Questions and can also provide Answers: class User < ActiveRecord::Base has_many :questions has_many :answers end class Question < ActiveRecord::Base has_many :answers belongs_to…
Joe O'Driscoll
  • 289
  • 3
  • 13
0
votes
1 answer

Why find(:last) fail in my unit tests?

I have a one-to many relationship in Rails: class User < ActiveRecord::Base has_many :activities, :order => "added_at DESC" class Activity < ActiveRecord::Base belongs_to :user I have a method in Activity: def self.test_message(user,…
Mike Sutton
  • 4,191
  • 4
  • 29
  • 42
0
votes
2 answers

Can't Redirect to User Profile After Follow

I'm using the acts_as_follower gem. I'm also using Devise for my user model and instead of a format like users/:id, I've allowed users to have username URLs. I'm working on allowing users to follow each other, but after a user is followed, Rails…
Alex Smith
  • 191
  • 2
  • 9
0
votes
1 answer

how to create relationships many to many from array of users

I get a couple of user objects in @users. and i have a task object in params[:task] Now i want to save the taskobject and add relationships between all @users and that task.... @users = User.find(session[:user_id], params[:user_task]) @task =…
Frida k
  • 41
  • 7
0
votes
2 answers

Rails Format Collection_Select Based on two relationships

I'm trying to figure out how to construct a collection_select to include two relationships. Here are my models: class Country < ActiveRecord::Base has_many :companies, :dependent => :destroy end class Company < ActiveRecord::Base belongs_to…
calabi
  • 283
  • 5
  • 18
0
votes
1 answer

Rails: has many relationship - determine which related object from within method

I have two classes with the following relationships/methods: class Bar has_many :foos def bar_method #puts the specific foo that called it end end class Foo belongs_to :bar def foo_method bar.bar_method end end When calling…
user1032752
  • 751
  • 1
  • 11
  • 28
0
votes
1 answer

EF : related entities are set as INSERT instead of being only referenced to the added entity

I tried to find an answer through the related questions I got but I didn't see the same situation I have now. I a beginner with this framework. The thing is that in the DB the TopicFeedbackType is always referred but TopicNavigatedUrl and Product…
Cedric
  • 1
0
votes
0 answers

Import Json data into Core Data with the relationships

I have a model with two entities: Country and City Country has one attribue "countryname" and a "to many" relationship attribute called: "cities" City has one attribute "cityname" and a "to many" relationship attribute called: "countries" Country…
0
votes
1 answer

How can I set an object to be a child of another in my rake task w/o mass-assignment?

This is my first Rails project and this seems like a very simple issue, but I can't seem to find any examples. I don't know how to create an object and set it to be a child of another already existing object. In this case I have a City and a…
jhonsmc
  • 23
  • 8
0
votes
1 answer

Filemaker main overview table records

I have two tables: businesses and leads. businesses is the parent table; A record in businesses may have many leads. My leads table holds data like "calls, appointment, etc etc" - all searchable. I'm trying to create a layout to sort all of my…
Vermino
  • 33
  • 1
  • 9
0
votes
1 answer

Rails has_many belongs_to same form

So I have albums and album_tags. One album can have many album_tags so that I modified the models: class Album < ActiveRecord::Base ... has_many :album_tags end class AlbumTag < ActiveRecord::Base attr_accessible :album_id, :album_tag_id,…
user1697061
  • 255
  • 3
  • 14
0
votes
1 answer

Fluent NHibernate Unidirectional relationships causing many updates

I have done some search on StackOverflow and google in general and I am still having trouble finding out why this is happening and how to fix it. I am new to NHibernate and FluentNHibernate, so please be gentle :) While doing some intergration…
Phillip
  • 229
  • 2
  • 14
0
votes
1 answer

Generic Relation Constraints in Django

I want the a counterpart of Tag (BlogPost) to have at least 1 instance of Tag or it shouldn't be created. (same effect like null=False). I tried a lot but couldn't figure out to apply these contrains. Any ideas? class Tag(models.Model): …
j7nn7k
  • 17,995
  • 19
  • 78
  • 88