similar to: Update HABTM

Displaying 20 results from an estimated 50000 matches similar to: "Update HABTM"

2006 Nov 04
0
Model.delete_all vs Model.destroy_all in a habtm
Hi there I have an habtm association between 2 Models. I regularly have to truncate the table on one side of the relationship and repopulate the table with a fresh csv file. I notice that f I do Model.delete_all, none of the records in my habtm join table get deleted, whereas if I use destroy_all they do. However, the overhead of using destroy_all is too great. For the amount of records I have
2006 Jan 19
0
Help with nested HABTM relationship
Hi, I am trying to perform a query with ActiveRecord that I want to put into a Rails application later. For now I just wrote it within a plain old Ruby script for easier testing. I am working with an existing database so I had to map some foreign keys myself. As you can see from the models below, the database has a structure of Prospectlists <=habtm=> Contacts <=habtm=> Accounts
2005 Dec 16
0
More HABTM Save Problems/Issues.. bugs?
I seem to be having a problem working with an object which has a HABTM relationship with another object I know there''s been a lot of talk recently about problems using dual HABTM in a single object but I believe this may be a separate issue. It appears like I''m unable to persist this relationship (i.e. the object saves but none of the entries in the join table are
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 20
0
No Magic for HABTM forms?
Hi, I posted yesterday asking how to get form tags to reference the associated objects in a habtm relationship. I was hoping for Rails Magic, but it looks like Rails doesn''t have habtm magic beyond a certain point. Here was my solution for others who might have the problem. Also, I hope someone shows me that there is a simpler way. The Database Model: class Registration <
2006 Jun 07
1
How do YOU read/update HABTM?
In my mind, it should work like this: <%= select ''item'', ''category_ids'', Category.find(:all).collect {|c| [c.name, c.id] }, {}, {:multiple=>true, :size=>20} %> Then Rails should automatically populate and update HABTM on that. As it is now, the above won''t work (I created a getter in item''s model that returns an array of
2006 Jun 29
0
HABTM and select form helper
I am very confused about HABTM and a form select statement that I need to implement. I have two objects - Person which has the following fields: id, firstname, lastname, email Category which has the following fields: id, name A person HABTM categories and also the reverse. I have setup the join table using a migration. All that went well. Two questions - If I want to edit a person, how do I
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>
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 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,
2006 Jan 04
2
Updating Attributes in a HABTM Join Table
Is there a way to update attributes in a HABTM join table? Right now I am deleting the join and then recreating it with new attributes. I have a table "categories" and another table "items". They are both HABTM with the join table "categories_items" between them. If an item is joined to a category once, no problem, we create the join. But if an item is
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
2007 Oct 15
0
converting from HABTM to has_many :through
Hello, I have a has_and_belongs_to_many relationship that I''ve realized I need to add additional attributes to. So I''m converting it to a has_many :through (HMT) relationship. This is the first time I''ve used an HMT, and it seems like I''m using too much code. I couldn''t figure out how to get the join model objects to update automatically as a result of
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 advance PS I just posted this in the
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
2007 Apr 08
0
select html for habtm
How does one use a <select> for a habtm field? I''m having trouble getting it to work. Here''s my html: <div> <p><label for="projects">Project</label><br/> <select id="schedule_projects" name="schedule[project_ids][]" multiple="multiple" size="10"> <%=
2005 Aug 11
0
No-brainer HABTM vs. select input question
Pardon my newbness. I''m trying to create, populate, and save an object with an HABTM mapping. That''s not working too well so far ;) Assuming I have the mapping correct (HA!) and the db set up properly, how do I create the select and options? I guess mostly I want to know what I''m supposed to name it. I have a FilingEvent class - HABTM State (both models have the
2006 Jul 12
1
odd habtm behavior? or is it me?
Hello List, I''m a bit spent on this problem, and my code might be whack. I seem to be encountering a problem where the primary key on a join table is not being resolved correctly. I will elaborate after some code bits. I am creating the join table using migrations, and relevant model code is this: class Post < ActiveRecord::Base has_and_belongs_to_many :records
2006 Jun 29
2
HABTM with multiple select list
Hello, I am very new to ruby and need to create my first HABTM with multiple select list.  I am having problems saving data in the middle(linking) table.  1. titles can have multiple categories  2. categories can have multiple titles Categories, titles and categories_titles tables are created.  ----- title_controller.rb--   def new     @title = Title.new     @categories =
2006 Jun 11
2
HABTM Duplicates?
Hello all, I''m working on a small Rails site for a game I play that will be used to add new characters. Part of this addition process is choosing what skills the character will have. For this, in MySQL, I have a characters table and a skills table, as well as a characters_skills table that is used as the join table in the habtm relationship between the two. I am presenting the skills in