similar to: Table w/ 2 columns feat. the same foreign key (accessing?)

Displaying 20 results from an estimated 10000 matches similar to: "Table w/ 2 columns feat. the same foreign key (accessing?)"

2007 Aug 30
1
belongs_to with foreign keys that reference non primary key columns
Hello, I have a situation where the foreign key into a table doesn''t correspond to that table''s primary key: my_table ------------- id (pk) name ... other_table -------------- id (pk) my_table_name (fk references my_table(name)) ... I want to be able to say something like: class OtherTable < ActiveRecord::Base belongs_to :my_table, :foreign_key => { :my_table_name
2006 Apr 07
6
Foreign Key naming convention override
I am working with an existing database and have to keep all table and field names as they are. ''tblcustomers'' and ''tblitems'' are linked by the ''tblcustomers'' id field ''tblcustomersid''. In ''tblitems'', the foreign key is called ''txtcustomerid''. I have already set the customers model to
2005 May 24
2
Deleting from a 'has_many' collection doesn't set the foreign key to NULL
Hi all, I have an Active Record problem. Having this classes declaration. class Sale < ActiveRecord::Base has_many :sale_line_items, :class_name ''SaleLineItem'' ... end class SaleLineItem < ActiveRecord::Base ... end When I try to delete an item in a Sale class method from sale_line_items (sale_line_items.delete(li)), it extracts ''li'' from
2006 Jul 10
10
has_many :through and foreign key parameters
I just took my HABTM and turned it into a :through since my join table has another "non-joiny" attribute. I went from this: has_many_and_belongs_to :jobs, :join_table => ''tablename'', :foreign_key => ''x'', :association_foreign_key => ''y'' to this: has_many :jobs, :through =>
2005 Feb 09
1
cant map foreign key in list view
Hi I have been struggling to get a foreign key in a list map to a readable value in a lookup table I have a list of projects and each project has a project_manager. Project.rb class Project < ActiveRecord::Base has_one :project_manager, :class_name => "Users", :foreign_key => "manager_id" end The association above sais that a project_manager is in
2006 Jun 21
1
Migration with foreign key won''t work
Hi all I use the plugin which supports foreign keys with migrations: http://wiki.rubyonrails.org/rails/pages/Foreign+Key+Schema+Dumper+Plugin/versions/12 I have created the following migration file: class AddArtistsTable < ActiveRecord::Migration def self.up create_table :artists, :force => true do |t| t.column :name, :string, :limit => 100 t.column :artist_type_id,
2006 Aug 14
1
2 foreign keys to one table
Hi, I have a messaging class that has to relationships to one table belongs_to :user, :foreign_key => "from_id" belongs_to :user, :foreign_key => "to_id" At the min I can specify message.user.login and it will return the username of last relationship to that table. how can I get it to bring back both references ie message.from.login and message.to.login thanks scott
2006 Apr 11
1
Foreign Keys
Hi, My tables are as follows: "tblusers" - primary key "TblUsersID" "tblregisteredphones" - primary key "TblRegisteredPhonesID" - foreign key "intUserID" My models are as follows: class Registeredphone < ActiveRecord::Base set_table_name "tblregisteredphones" belongs_to :user, :foreign_key
2009 Feb 21
2
Foreign-key confusion
Hi, I am a bit confused about managing the relationship between two of my tables: I have developed a script using scRUBYt that scrapes data from a website and dumps the following four fields into my Shows table: class CreateShows create table :shows do |t| t.string :date t.string :venue t.string :info t.string :comics The second table I created is called Theatres: class
2012 Feb 14
2
Model with 2 foreign keys
Hi All, I''d like to integrate a simple user-oriented messaging system into my app. I have a Message model, with :from_user_id, and :to_user_id (for the user that sent and the user that recieved the message). Obivously, (User) has_many :messages will fetch the messages that a certain user has created, but not the ones that they have been sent. Currently, I have this: has_many :messages,
2006 Jan 09
0
Foreign key with 2 or more fields in a relationship
In rails with a 1-M or M-M relationship you can use :foreign_key = ?xxxxx? to override the default foreign key which will be used. Is it possible and if so, how do you specify a foreign key for a relationship which has two or more fields in it? -- Posted via http://www.ruby-forum.com/.
2006 Jan 03
4
Set the foreign key constraint column name?
I am applying Rails to an existing schema and not sure how much the existing developers will let me go in and rename things. So I need to discover the limits of what I can change with Rails. I''ve found set_table_name and set_primary_key, which have been very useful. If I have a "foo has_one :bar" relationship, but then in the bar table my column is named "fooid"
2006 May 24
4
AR foreign key problem.
Hello Railslist, (I''m using RadRails 0.6.3 on Windows XP with Ruby 1.8.4, Rails 1.1 and SQLite3) I have two tables in the database: "locations" and "customers": customers.sql --- id INT PRIMARY KEY name VARCHAR 255 address VARCHAR 255 postal_code VARCHAR 255 city VARCHAR 255 --- locations.sql --- id INT PRIMARY KEY postal_code TEXT longitude FLOAT latitude FLOAT
2007 Oct 16
8
Using multiple foreign keys in views
I have a model, Game, that has_many :teams. There''s a home team and an away team. I created two foreign keys, so each game can have two teams associated with it. Here''s the Team model: class Team < ActiveRecord::Base belongs_to :game, :class_name => ''Game'', :foreign_key => ''hometeam_id'' belongs_to :game, :class_name =>
2008 Apr 18
3
has_many and belongs_to with non-primary foreign keys
Hi, I''m having a bit of trouble with my first Rails app. ---- I have two tables: create_table :items do |t| t.column :created_at, :timestamp t.column :user_id, :int t.column :text, :text end create_table :users do |t| t.column :user_id, :int t.column :name, :string end ---- I''m trying to use the "user_id" field to link both tables, with each user
2007 Oct 07
2
How specify foreign key column name in model?
In a model declaration I can specify the name of the primary key column with set_primary_key "CUSTOMER_NUMBER" How can I set the name of a foreign key column that does not conform to the RoR naming convention. Does the following work? set_foreign_key "CUSTOMER_NUMBER" If not, how can I specify the name of the foreign key column? Thanks.
2011 Feb 26
1
How to manage the form of a model that has two foreign keys
Hi, Basically I have two models: User and Godfather. The godfather table has three columns: - user_id (FK --> User) - user_godfather_id (FK --> User) - description (text) Inside each model class, I am adding the following associations: class User < ActiveRecord::Base has_many :godfathers # for user_id has_many :godfathers, :foreign_key =>
2006 Apr 06
4
using two foreign keys to the same table
i am working on a task manager with ruby on rails. it is my first major project, so i''m still gettng my feet wet as i learn. i''ve been trying to use the built in relationships to link my tables together, but i''m not able to use the same naming conventions. for each task, it has a field for the creator, and another field for the assignee. both of these fields
2014 Mar 30
0
[feat request] flag for CD de-emphasis
I just found out about CD emphasis, a redbook feature that was sometimes used in mastering to reduce noise with historic 14-bit ADCs that did not over-sample and had noisy brick-wall. I haven't gone through all my CDs but so far, only my Tom Petty "Southern Accents" from 1985 seems to have it.
2006 Jun 22
1
Sharing primary key between two tables?
Hello, I have an ActiveRecord question. I have two tables, "customers" and "users". Those two tables really should share their primary key, in order to have a "real" 1:1 relationship. (I don''t mean to start a database-resign religious war, but I must say that I do feel very uneasy about using ActiveRecord''s "normal" way, which is to