similar to: Prevent an object from being destroyed in HABTM relationship

Displaying 20 results from an estimated 7000 matches similar to: "Prevent an object from being destroyed in HABTM relationship"

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
2017 Aug 28
0
regex - optional part isn't considered in replacement with gsub
"Please, consider that some SKUs have "-" in the middle, for example: "PG-9021". Then you need to include these in the list of patterns you gave. Try it again -- this time with a **complete** list. -- Bert Bert Gunter "The trouble with having an open mind is that people keep coming along and sticking things into it." -- Opus (aka Berkeley Breathed in his
2008 Dec 16
1
Callback when objects connect as a habtm relationship
If Product and Category models are in a habtm relationship, i.e. class Product < ActiveRecord::Base has_and_belongs_to_many :categories end class Category < ActiveRecord::Base has_and_belongs_to_many :products end I want a piece of code to be executed every time a product is connected to a category. Where do I put this code? Which callback (and on which model) will be triggered? Any
2017 Aug 27
0
regex - optional part isn't considered in replacement with gsub
Omar: I don't think this can work. For example number-letter patterns 4), 5), and 6) would all be matched by pattern 6). As Jeff indicated, you need to provide the delimiters -- what characters come before and after the SKU patterns -- to be able to recognize them. In a quick look at the text file you attached, the delimiters appeared to be either "-" or " " (blank) and
2006 Mar 23
0
HABTM relationship
Hi all, I''ve got the following two objects and the habtm relationship isn''t putting records in the DB: class Cse < ActiveRecord::Base has_and_belongs_to_many :conditions end class Condition < ActiveRecord::Base has_and_belongs_to_many :cses end I''m creating a Cse object and filling the collection of Conditions, then calling save on the Cse object.
2006 Jun 14
3
Prevent duplicate HABTM associations
Hi, I am trying to restrict duplicate has_and_belongs_to_many associations. I tried to find support for a association validation for duplicates but couldn''t find anything. I understand I could use :uniq=>true on the model association but this would only prevent it from displaying duplicates, I want to stop duplicate associations being inserted in the first place. I have a vague
2006 Nov 14
3
messed-up habtm relationship
Hi, I have a many-to-many relationship between dishes and ingredients class Dish < ActiveRecord::Base has_and_belongs_to_many :ingredients end class Ingredient < ActiveRecord::Base has_and_belongs_to_many :dishes end I have a join table dishes_ingredients now when i access my_dish.ingredients, i get a list of what looks like Ingredient objects, but the but they don''t have
2009 Oct 04
1
circular relationship - habtm
So I have 2 models: Picture and Comment. Pictures have many Comments, but I''d like for users to be able to post Pictures in Comments, so Comments will have one Picture (possibly). This creates a kind of circular relationship it looks like, and the only way I could think of to implement this is with has_and_belongs_to_many. Am I right, or is there a better way to do this?
2006 May 12
2
How to declare several HABTM-relationships?
Hello, Is it possible to have several HABTM-relationships for the same object? Example: Imagine I have 3 objects (classroom, student, teacher) and define the associations for the student as: class Student < ActiveRecord::Base has_and_belongs_to_many :classrooms has_and_belongs_to_many :teachers class Classroom < ActiveRecord::Base has_and_belongs_to_many :students class Teacher <
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''t support multiple
2005 Dec 15
2
HABTM being tricky
I''ve just been bodyslammed by a problem with has_and_belongs_to_many - as far as I can tell, if it doesn''t appear at the top of other relationship definitions it doesn''t seem to work right. For example: class Artist < ActiveRecord::Base has_and_belongs_to_many :genres has_many :albums has_many :videos has_many :cds has_many :collections end ..works fine
2005 Jun 03
1
sorting on a habtm relationship
I have two tables ("products" and "categories") that have a has_and_belongs_to_many relationship, and I need to be able to arbitrarily sort products in the scope of a category using something like acts_as_list. Problem is, since each product can belong to multiple categories, it doesn''t work to use acts_as_list and have the "position" field be in the
2006 Jun 20
1
Preventing Dups in HABTM
I have a habtm that looks like: report has_and_belongs_to_many :subscribers subscriber has_and_belongs_to_many :reports When I add a report to a subscriber, I have to run code like: raise "already there, idiot!" unless report.subscribers.find_by_id(subscriber_id).nil? Is there a better way to avoid adding duplicative associations? has_many :through seems like overkill for this
2010 Sep 01
0
Error on update_attributes with HABTM relationship
Hope someone can tell me what''s up, because this has me baffled. I have an Image model, and a Provider model. Both are defined as "has_and_belongs_to_many" relating to each other. In my image form partial, I have a bit of AJAX generating the provider_ids array dynamically from a provider AJAX search on the same page. So for example, each time I click on a provider name that
2017 Jul 19
0
[ANNOUNCE] libdrm 2.4.82
Anusha Srivatsa (3): intel: PCI Ids for S SKU in CFL intel: PCI Ids for H SKU in CFL intel: PCI Ids for U SKU in CFL Ben Widawsky (1): intel/gen10: Add missed gen10 stuff Christian Gmeiner (1): etnaviv: submit full struct drm_etnaviv_gem_submit Dave Airlie (6): amdgpu: sync amdgpu_drm with kernel. drm: update drm.h to latest in drm-next. libdrm:
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 Feb 28
8
HABTM count table
Hello, I have a question about HABTM and counting records. I have these models class Sort < ActiveRecord::Base has_and_belongs_to_many :reports end class Report < ActiveRecord::Base has_and_belongs_to_many :region has_and_belongs_to_many :subjects has_and_belongs_to_many :sorts end And i would like to get a count like @sort.reports.count The problem is get this query:
2006 Jan 12
1
Saving habtm relationships and Rails 1.0
I know there''s a problem saving has_and_belongs_to_many relationships w/ Rails 1.0 in that only the first association is saved (http://dev.rubyonrails.org/ticket/3213). What are people doing about this? I guess I could move to using the trunk release, but I''m hesitant because that might introduce a bunch of unknowns. Is there a workaround? For example, a way to explicitly
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 <
2011 Jan 14
0
[Rail3] How to construct full-text search for habtm associations
hi all, i''m new to this group and currently using Rails 3.0.3 and meta_where 0.9.10. i''m considering how to make a full-text searching feature to my project, and my models, for example, should be defined like below: class Group < ActiveRecord::Base has_and_belongs_to_many :users # :title (string) end class Comment < ActiveRecord::Base has_and_belongs_to_many :users