similar to: Single table inheritance and relations

Displaying 20 results from an estimated 10000 matches similar to: "Single table inheritance and relations"

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 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
2005 Dec 19
8
Single Table Inheritance question
Hello, I''m having a heck of a time getting Single Table Inheritance to work in my app. I have the following models and have scaffolded out Person and Contact. person.rb class Person < ActiveRecord::Base has_many :contacts end client.rb class Client < Person end contact.rb class Contact < ActiveRecord::Base belongs_to :person end phone.rb class Phone < Contact end In
2005 Dec 29
9
Single Table Inheritance
Hi all, Quick question for STI. With the following setup: class Company < AR::Base; end class Firm < Company; end Why does Firm.find(:all) return all Companies, not just those that have type==''Firm''? -- Alex
2007 Jan 08
1
Realtime Voicemail Table Column Name Question
Hi All, In the realtime voicemail table the column 'customer_id' is used, for my purpose, to specify the customers accountcode. The column name 'accountcode' is used in the iax and sip tables. To keep this consistent throughout the tables, is there any reason I should NOT switch the column name 'customer_id' to 'accountcode' in the voicemail table? Does Asterisk
2006 Jan 05
6
Inheritance Question
Hi, My application has a table of People that has information about them, and I want to have a subset of those people as Users - people that can login to the application. What is the best way to do this? Add columns to People that only Users would use? I''ve read the threads on single table inheritance, but it seemed a little bit wasteful: 10,000 people vs 50 users For those more
2007 May 28
5
CTI in ActiveRecord
I search an plugin or gem, but don''t find nothing satisfactory. I believe to be stranger a technology that nails the DRY, have that create you vary equal tables, instead of using inheritance. Exists an soluction for this? I want a solution similar to this: create_table :people |t| do t.column :name t.column :address end create_table :customer |t| do t.column :person_id
2009 May 14
3
Mysql query is not working
Please, Can anyone help me to execute this query? SELECT * FROM table WHERE customer_id IN (SELECT IF(1 <> 2,''SELECT customer_id FROM customers'',''SELECT customer_id FROM company'')) Regards... -- Posted via http://www.ruby-forum.com/.
2013 Feb 18
6
How to clear ActiveRecord query cache on associations with dynamic table
In part of my application I''m using dynamic tables. I''m aware of the single thread conditions. I''ve tackled some caveats yet - will post a blog about it soon - but there''s one I need help with. Consider 2 models that are associated: Order and OrderLine where Order has many order_lines. Now we set the table names for them:
2006 May 26
3
Breakdowns in has_many abstraction
I discovered an interesting aspect of has_many behavior that I''m struggling to work around. I''m not sure if I''m doing something wrong, or if it''s a legitimate bug, or if it''s an inherent part of Rails that I just have to learn to deal with. It boils down to these two problems: - changes in collection objects (i.e. models that belong_to a container
2006 May 28
3
Association of table to itself
I''m curious what would be the best way to represent people and whether the person has someone marked as their friend. Here are my thoughts so far: People table - id - name Relationships table - person_id - friend_id Now my problem is I don''t know how to set up these associations (if this is even correct). Friend_id would be an id to someone else from the people table.
2009 Feb 27
4
Optimize for loop / find last record for each person
I want to find the last record for each person_id in a data frame (from a SQL database) ordered by date. Is there a better way than this for loop? for (i in 2:length(history[,1])) { if (history[i, "person_id"] == history[i - 1, "person_id"]) history[i, "order"] = history[i - 1, "order"] + 1 # same person else history[i,
2007 Sep 21
2
ActionWebServer and SOAPFault
I''m really new to RoR and my first task is to write SOAP web service. The problem is that I don''t understand how to send custom SOAPFault messages in case of the errors. For example, I have FindCustomerById API signature: api_method :find_customer_by_id, :expects => [{:customer_id => :int}], :returns => [Customer] And controller: def
2005 Mar 04
3
optimization
Ok, so, I''ve written my first app in rails. It''s pretty nifty. Only one problem. Slower than you could possibly comprehend. Processing PersonController#show (for 67.138.254.231 at Thu Mar 03 21:04:16 Eastern Standard Time 2005) Parameters: {:id=>"1", :controller=>"person", :action=>"show"} [4;35mPerson Load (0.219000) [0;37mSELECT
2006 Mar 18
1
Fixtures and single table inheritance
I''m wondering what the accepted method for doing unit tests on STI models is. I tried to create a fixture for the class but Rails tries to load that data into the non-existent child table. I could create a fixture named for the real, parent table, but then it would be very difficult to test for the individual functionality and integrity of each sub-class. I saw this page
2007 Nov 14
1
New Foxy Fixtures (Rails 2) & STI (Single Table Inheritance)
I''ve got some problems right now using the new model for relationships in fixtures (by label, not by id) and STI. What I''ve got, is a couple of models: Attachment --> FileDownload Version Version has_one file_download with file_download_id on the versions table In my fixtures, I have two FileDownloads in my attachments.yml like so: hemingway_alpha_zip: size: 100
2007 Mar 07
4
Strange Problem With Unwanted, Transient Caching
Hello, I hope somebody can explain to me what''s going on here because I''m baffled! In a controller''s action I want to create a new order for a customer. Because I post back to the same action (not RESTful I know, but that''s for another day) I use code like this: def edit @order = Order.find_by_id(params[:id]) || Order.new ... end I
2006 Mar 13
3
HABTM: two habtm''s between the same two tables
Imagine I want to track people, and the clubs that they belong to. table people with columns person_id, person_name table clubs with columns club_id, club_name And I have the association table: table clubs_people with columns person_id, club_id Now I know how to do this habtm between the two, in order to associate people with clubs that they belong to. However my application also needs a
2006 Jul 26
3
Polymorphic Association with Single Table Inheritance?
Hello, is it possible to setup a model/table schema like this: Groupable --> Membership <-- Group ^ ^ | | User UserGroup I tried the following but failed: Groupable (table with ''type'' column) has_many :memberships, :as => :groupable has_many :groups, :through => :memberships
2006 Aug 02
2
many-to-one relationship, do I need a second table?
Ok, to keep things short. Im wondering if I need a secondary relationship table to handle my many-to-one relationships. Here is an example of what I''ve written down. For instance say I want to find all of the people in a given location. class Location < AR:Base has_many :people end class Person < AR:Base belongs_to :location end My SQL tables look like: CREATE TABLE