similar to: HABTM question

Displaying 20 results from an estimated 10000 matches similar to: "HABTM question"

2007 Jul 26
1
Bi-directional self-referential HABTM
Hi, I''m having a little trouble figuring out how to make a self- referential HABTM bi-directional. I have a Employee class. Each employee can have a couple of bosses, who are also employees. The employee class has the following HABTM: has_and_belongs_to_many :bosses, :class_name => "Employee", :join_table => "bosses_courses", :association_foreign_key =>
2006 May 17
2
Association data clobbering (foreign keys too?)
Can someone please confirm or correct the following statements? If I have the following tables create table as (id int, [...], b_id int); create table bs (id int, [...], a_id int); create table as_bs (a_id int, b_id int); and the associations woould be defined like this class A << ... habtm :bs belongs_to :b end so my Model A has a habtm collection of Bs *plus* a direct
2008 Jul 21
3
Asymmetrical HABTM(?)
What is the best way to set up a relationship between two tables where table-1 has a one-to-one relationship with table-2 but table-2 has a one-to-many relationship with table-1? For example, suppose there is an events application (seminars, forums, conferences, etc). Each event has only one address but since many events can occur at the same location throughout the year, a given address can
2006 Jun 30
2
how to HABTM with STI ??
Hello all This is my first post so excuse the basic question. (and any repeats I just got an email saying this post was too big so I have re-submitted a smaller version) I was following the thread on http://lists.rubyonrails.org/pipermail/rails/2006-May/038988.html regarding the STI on HABTM for RoR. I have a very similar problem and was hoping for some help. I have the
2006 May 24
2
"Stack Level Too Deep" issue in HABTM Unit / Functional Test
Hello guys. I was able to figure out that my "stack level too deep" error I was getting with my HABTM destroy method was the result of a bug in rails 1.0. I upgraded to 1.1.2 and now the views and any console-run commands for destroying AR objects linked together via HABTM work just fine. I have HABTM setup between stories and submissions. The issue is that the destroy methods in
2006 Feb 21
7
Self-referencial habtm relationship
Heyo! I am setting up a self-referencial habtm relationship with the users of my app. I am using Chad Fowler''s "Rails Recipes" to get me started, and everything works great with the join table "people_friends". I add friends by doing somebody.friends << somebodyelse. However, with my app, there is an approval process so my join table has columns person_id,
2006 Jul 10
7
What is has_many :through really buying you over HABTM?
So having just learned how to do has_many :through as opposed to HABTM, and then, being concerned that I wouldn''t get it to work, I started thinking about these two approaches. It seems to me that the _only_ problem that the HM:T (has_many :through) approach solves that HABTM doesn''t is the issue of the potential collision of id columns between your join table and one of
2006 Jun 05
7
Is HABTM Dying?
For a while, I''ve been getting that HMT is replacing HABTM. It appears that HMT can do all of what HABTM can do and more. The question is: Should I stop using HABTM? Let''s take a simple case: A case has many categories For a given category, there are certain valid statuses Category has_and_belongs_to_many :statuses Status has_and_belongs_to_many :categories Question: Is
2006 Mar 05
1
Help with Self-Referential HABTM
With the help of the Rails Recipes have got a self-referential HABTM relationship working, but I''m really struggling with getting a new entry from a form accepted. i should say here that the form is also submitting info for the join table too. So in my model I have: class Type < ActiveRecord::Base has_and_belongs_to_many :subtypes, :class_name => ''Type'',
2006 Feb 09
2
select options for HABTM?
I''ve looked through the docs and the wiki and can''t figure out how to go about generating select options and the update function for an item that has a HABTM relationship. I have a ''parks'' table and the park model has a HABTM to the ''states'' table. On the park edit page, I''d like a multiple select box to appear with all states show,
2006 Jul 10
4
HABTM vs. using has_many :through
All, I''ve heard recently about has_many :through as a necessary alternative to HABTM (when the join table has it''s own id column, say, in a legacy schema). However, is the prevailing Rails wisdom now that one should use has_many :through in _all_ cases? If so, why? Thanks, Wes -- Posted via http://www.ruby-forum.com/.
2006 Jan 20
11
HABTM relations
Hi, I have 3 tables with HABTM relation. USERS -> QUOTE_TO_USER <- QUOTES Table QUOTE_TO_USER has 3 attributes: quote_id, user_id, component. I have a form where I can tie multiple users to QUOTE. This is easy one, thru "user_ids" (@quote[:user_ids] = @params[:quote][:user_ids]). In this form I have all users and I just check those I want to tie to this quote, however
2006 Feb 14
1
Another HABTM Question
Hi there, I have a question on what would be the best way to save a HABTM model. A posting habtm categories, and a category habtm postings. class Category < ActiveRecord::Base has_and_belongs_to_many :postings end class Posting < ActiveRecord::Base has_and_belongs_to_many :categories end In my blog_controller, where the actual posting is saved, is where I think I''m
2006 Feb 23
1
Pretty HABTM check boxes
I''m 100% positive this has come up multiple times before. I just can''t find it for some reason. I''ve got a HABTM relationship, we''ll just say Item HABTM categories. When I edit an Item via a form, I''d like there to be check boxes for all the categories, and they''ll obviously be checked if an Item has a relationship with a particular
2006 May 01
4
Find rows with associations in habtm
This may have been asked/answered before - if so, i apologise... I have the following table layout in a habtm relationship: ------------ ----------------------- -------------- | products | ----| categories_products |-----| categories | ------------ ----------------------- -------------- What would be the best way to pull out all the products for a given category? At the
2006 Jun 20
2
habtm, multi select, and validation
Greetings - I''m trying to find the most efficient, "Rails" way to solve the following problem. It''s in two parts, but I think the solution is somewhat related: I have Recipe and Category model related by HABTM. I would like to 1.) Validate the *number* of categories associated with a recipe, say a minimum of 1 and a max of 3. (So validates_associated will not
2006 Dec 29
4
Strange HABTM behavior against SQL Server (AR 1.14.4)
All, Win XP SQL Server 2000 Rails 1.1.6 (AR 1.14.4) I have two objects (Job and Warning) in a HABTM relationship. Below are the pertinent sections of the model files and the schema for the join table. job.rb: class Job < ActiveRecord::Base has_and_belongs_to_many :warnings, :foreign_key => ''JobReferenceNumber'' set_table_name :JobData set_primary_key
2006 Mar 21
2
Need :through to work as has many rather than HABTM.
I''ve a horrible feeling I''m missing something here, but I''d like to have something like :through to model a has_many relationship rather than a HABTM relationship (and I don''t think it does). The is the model I have (simplified): Users have many Models (and Models belong to Users) Models have many Pieces (and Pieces belong to Models) In (badly drawn)
2006 May 07
4
Getting column value from lookup table in HABTM relationship
I have a HABTM relationship between my agents and listings tables. Each listing can have many agents and each agent can have many listings. In the agents_listings table I have a column called ''is_primary_agent'' which denotes if the agent is responsible for the listing - only one agent can be primary. At the moment I use this in my listing_controller''s view
2005 Nov 28
1
has_one / HABTM relationship overlap - please advise
1. I have a few tables: ''users'', ''shops'', ''addresses'', and ''pictures''. 2. Users and Shops will both use the addresses and pictures tables. I have created several mapping tables: addresses_shops pictures_shops addresses_users pictures_users 3. Users CAN have many addresses and pictures (simple HABTM), but... 4.