search for: habtm

Displaying 20 results from an estimated 495 matches for "habtm".

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_man...
2006 May 30
3
extra attributes in habtm
Hi, Posting here since issue tracking isn''t the best place to discuss. I can understand habtm is moving towards deprecating support for extra attributes in join_table, and to use :through for those cases instead. To clarify, patch<http://dev.rubyonrails.org/attachment/ticket/5216/habtm_join_table_test.patch1.diff>for #5216 <http://dev.rubyonrails.org/ticket/5216> wasn''...
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...
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 secondary association just like this: imagine I want to track the clubs that a person has APPLIED to join, but is not yet a member. So I have a second association table table club...
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 my unit tests...
2006 May 31
6
habtm on an array (or object.habtm.habtm)
Hi, I have three Models: User, Group and File. User habtm groups and Group habtm Files How can I find all files that a particular user has access to? eg user.groups.files ? As user.groups returns an array, the above doesn''t work. Id like to find the files for all groups in that array, without adding any code to the User model. Thanks in adva...
2006 Jan 12
8
Scaffolding support for many-to-many editing (habtm)?
Like with simple table editing, there are also typical ways of how a user usually interacts with one-to-many or many-to-many relations. For example, one would show the fields of one row of table1 in the screen and below a line-by-line view of all associated entries in table2. Then, one could press an "Edit" button and add or delete rows from table2 to this entry of table1,
2006 Apr 05
5
Updating attributes in HABTM association
Hi, I am trying to find a way tp update attributes in a habtm association. I am trying to use the code from ticket #2462, but as my association_class_primary_key_name seems to be empty the generated sql code is corrupt. I hope thats not a problem of my model that this variable is empty. What would you recommend to update those attributes (rails 1.1) THAN...
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 following models that employ single table inheritance and HABTM (see below for sql script showing tables). I read that the classes will inherit the HABTM relationship from the parent class. Eg Part should und...
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 Apr 26
2
HABTM with ajax_scaffold
has anyone managed to do this? It works great for has_one, belongs_to type stuff, but i cant seem to get a HABTM setup going. Any demo code or advice greatly appreciated. Excellent work on this tool by the way its really great work. adam -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060426/67138fa7/attachment.html
2006 Feb 16
1
HABTM -VS- belongs_to/has_many, for self-referential joins
Ok, David says on page 241 that sometimes a many-to-many relation with attributes are better implemented as an actual model instead of using HABTM. Well, I''ve got that situation and I can''t figure it out. All of the examples in the book have HABTM examples between 2 different tables, but I want to have a HABTM relation on 1 table with itself. (e.g., if I have a table Things, then I would like one "Thing" to &qu...
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...
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, and those in the parks_states table selected. Does anybody have some example...
2006 Aug 09
3
HABTM and getting to arrays from either direction
I didn''t find exactly an answer on this one, so I''d like to get a clarification from folks who live & breathe HABTM. class foo has_and_belongs_to_many :bars end class bar has_and_belongs_to_many :foos end (and yes, I have a bars_foos table in my db) def test_habtm bar = Bar.new foo = Foo.new foo.bars<<bar assert !foo.bars.empty? assert !bar.foos.empty? end My first assert passes just fi...
2006 Mar 28
3
Rails 1.1: Is HABTM obsolete?
Does the new has_many :through and belongs_to :through obsolete (well, replace and essentially deprecate) has_and_belongs_to_many? Joe -- Posted via http://www.ruby-forum.com/.
2008 Dec 09
4
HABTM checkboxes insert but don't delete
I have a problem related with the HABTM relationships with checkboxes. I''ve got a profile and a service model, both related with has_and_belongs_to_many. The problem is that i can insert new data in the profiles_services table, however, i cant delete already existing data. What could be the problem? --~--~---------~--~----~-...
2006 Jan 19
5
Multiple HABTM relationships with self ???
I need to have a table related to itself via a join table. Will HABTM support this? That is: class Recipe < ActiveRecord::Base has_and_belongs_to_many :recipes, :join_table => "recipes_recipes" end More importantly -- how does RoR support MULTIPLE self-joins? I.e., to relate the table to itself via multiple join tables. SFAIK, HABTM won'...
2006 Apr 30
2
HABTM: Find sorted by number of associations
Hi, I''ve been googling and searching the forums for some time but can''t seem to find exactly what I''m looking for. Suppose User HABTM Products (for example a favorites list). I would like to construct a single query for finding Products ordered by the number of Users that have flagged them as favorites. Although I can construct the query using SQL a with a SELECT products.*, count(products_users.user_id) FROM products LEFT...
2006 Mar 12
0
NameError when trying to combine Recipe 14 (rich HABTM) & Rec. 10 (self-ref HABTM):
Hi all, I''m trying to model self-referential relations between people, where the relation has attached data. John ''works for'' Bob Problem: '':through'' doesn''t work, and generates a NameError. => the models : Person (attr: name) Relation (attr: source_id, target_id) (more details below) ex: John ''works