similar to: Aggregating two objects of the same type

Displaying 20 results from an estimated 3000 matches similar to: "Aggregating two objects of the same type"

2006 Apr 08
2
one-to-one relationship confusion
Hello, I posted a similar email, earlier in the week, but I still must not be getting it. I have a customer that aggregates two addresses; a shipping address and a billing address. Addresses can also be referenced by other objects in a similar way, so I would really like to avoid putting the keys referencing the customer or other objects in the addresses table. Addresses are exclusively
2006 Jun 03
8
confused about ActiveRecord relationships
I am very confused about where to put the belongs_to and the has_one (and other relationship identifiers). I have read the RDoc and the agile book many times about this and I think i still see it backwards. Let me outline my app so you have an understanding... I have 2 tables: Schools { id, school_name, address_id } and Addresses { street1, street2, city, state, zip, country } *** this
2006 Apr 02
7
RANT: belongs_to -> refers_to
Every once in a while, I pipe up and whine that "belongs_to" should really be ''refers_to" [http://dev.rubyonrails.org/ticket/2130]. It''s time again. I''ve got a bunch of stuff going onto eBay, so, like any good engineer, I don''t just post it manually: I design a Rails-based inventory database that creates a semantically-correct XHTML/CSS auction
2006 Jan 13
4
Single Table Inheritance (this is my 3rd post :( )
Hi Everyone, I hope I get some feedback on my question. Here it goes. I have a situation here, I have a company table and then using Single Table inheritance it is of 3 types: class Company < ActiveRecord::Base end class Vendor < Company end class Customer < Company end class Agent < Company end Now I have a active record Association class QuoteSheet < ActiveRecord::Base
2009 Jun 24
1
accepts_nested_attributes_for :reject_if issue
I have the following models: class Order < ActiveRecord::Base belongs_to :billing_address belongs_to :shipping_address accepts_nested_attributes_for :billing_address accepts_nested_attributes_for :shipping_address, :reject_if => proc { |attributes| attributes[''has_shipping_address''] != ''1'' } def after_initialize self.build_billing_address
2006 Jun 01
4
how can I control when to commit a transaction?
hello it seems like this question has appeared a few times with no answer: how do you get rails to issue ''write'' statements (ie ''CREATE/UPDATE'') to the database without committing each time? I tried setting ActiveRecord::Base.connection.begin_db_transaction before calling any action on my object, but as soon as myObject.save or myObject.update is called,
2007 Nov 20
2
confirming that a model instance was correctly created from POST params
I''m wondering whether I''m wasting my time trying to verify that an addition I''ve made to legacy code is in fact setting a new attribute on a model. Substruct''s (http://dev.subimage.com/projects/substruct) OrderHelper contains this method: 1 def create_order_from_post 2 @use_separate_shipping_address = params[:use_separate_shipping_address]
2006 Nov 02
4
Still Having Problems With :through When Going To Same Table... Help... please :-(
I am having a problem with doing a :through that goes back to the same table. The following are my two classes: >>>>> class User < ActiveRecord::Base has_many :spanks has_many :spanked, :through => :spanks, :source => :spanked_user has_many :was_spanked_by, :through => :spanks, :source => :user end class Spank < ActiveRecord::Base belongs_to :spanker,
2006 Feb 14
6
Multiple associations to the same class
Hi, I cannot seem to create associations like this: class Project < ActiveRecord::Base belongs_to :manager, :class_name => ''User'', :foreign_key => ''manager'' belongs_to :liaison, :class_name => ''User'', :foreign_key => ''liaison'' end p = Project.new p.manager => 1 trying to retrieve associated objects
2006 Mar 31
3
Complex Through Statement
Quick Overview: I have an ''Employee'', some ''Merchants'' and some ''Products''. A ''Merchant'' has many ''Products''. An ''Employee'' has multiple ''Merchants'', depending on their relationship. For example, the Employee may be the enrollment contact for one merchant and the
2008 Jul 15
9
Beginner Question.
I''m just getting into RoR, coming from a long PHP background. So far I LOVE IT! I''m hitting a roadblock with updating my mysql database. For simplicities sake, I have 2 tables and here are the relevant columns. Table Users id name email Table Issues id createdby assignedto reportedby In my models I have everything mapped properly I believe. When I try to update the
2008 Jun 13
6
Newbie question on has_many
I have two classes: a Widget and a User. The User has an id that is referenced in two places on the Widget: owner_id and operator_id. How should I structure that reference for has_many? Thanks folks - I appreciate any help on this. --David --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails:
2006 Jul 07
3
Newbie Model question (HABTM?)
All, If I have a table that has several discrete fields that all point to the same associated field, how do I model it. Specifically, If I have a project table that has 2 fields: specifying_company, and responsible_company. And one table of associated companies, how do I do the :belongs_to / :has_many stuff ie. For a given project company A may be writing the spec, but company B may be paying
2006 Jun 06
1
Please Help with single table inheritance relationships
I''ve been searching the web, wikis, and more, and I haven''t turned up examples of how to have multiple entities in a single-table inheritance related to anything. I have an addresses table, but multiple entities can have Addresses: both Person (which has 2 addresses) and Retailer. I''ve been told that I need to use single-table inheritance, and this was my attempt:
2006 Mar 29
3
Self-referential many-many joins with :through
I thought I had this nailed but.. now I''m seeing spots.. I''ve included my models below, feel free to ignore them. I''m really just after an example that works. I couldnt find one on the wiki... which is fair enough considering Ricks patch: http://dev.rubyonrails.org/changeset/4022 that fixed them only went through 5 days ago.. Cheers -henster
2006 Jan 09
3
Include with two references of one model of the same table
Hey guys, I just came across this oddity, not sure what to make of it yet, but I think it might be incorrect behavior. When doing a @inst.find(:all, :include => ["hometeam", "awayteam"] ...) hometeam and awayteam are two references from a belongs_to that is of the same model and of the same table. I will get a pgerror stating that "matches", which is
2005 Dec 14
5
belongs_to and multiple foreign keys
Hi all, I''m confused about how I''m supposed to specify a belongs_to relationship when the table includes multiple columns that reference the same parent table. In my case I have a "schedules" table with "opened_by" and "closed_by" columns, that both reference the "users" table. In theory, they can be two different user ids. table
2006 Aug 02
2
Self-Referential has_many :through
Hello all. I am trying to create a self-referential has_many :through. I used the following site as a guide http://blog.hasmanythrough.com/articles/2006/04/21/self-referential-through but it still doesn''t appear to be working. I have two models. Person and Relationship. A person has many contacts (Which is another person) through relationships class Person < ActiveRecord::Base
2007 Jun 09
7
create 2 fk referencing the same table
Hi everyone! I have a problem with defining 2 fk referencing the same table. I have a Program table and a Team table. The Program should have an away team and a home team fk. From my understanding, "the fk column should be named after the class of the target table, converted to lowercase, with _id appended". But, in my case, I have 2 fk referencing the same table. How can I do this?
2005 Dec 19
4
need some help designing my messaging system
I am trying to create a messaging system for my users but I''m having a hard time designing my db. This is what i have in mind, but I am not sure if its the best approach. user has_one inbox user has_one outbox inbox has_many messages outbox has_many messages inbox table user_id outbox table user_id messages table box_id (refers to either inbox or outbox - how?) from_id to_id