similar to: HABTM - Destroy just the relationship

Displaying 20 results from an estimated 5000 matches similar to: "HABTM - Destroy just the relationship"

2005 Dec 23
6
file_column and HABTM
I have several models that will be using file_column by way of the "Picture" class (HABTM). Right now, all pictures are stored in: public/picture/image/1/filename1.jpg public/picture/image/2/filename2.jpg Is there a way I can dynamically define the "store_dir" based on the model? For example, if I have "user", "product" and "place" models all
2006 Feb 28
14
Multiple Models w/ acts_as_ferret
I have multiple models all with: acts_as_ferret :fields => [...] (models = profiles, blogs, comments ) When I restart the server and perform any crud operation on one of the above models, the index is created/updated. If I then go and perform any crud operation on ANOTHER model, ...the index from that first model is being updated. Any ideas? Can acts_as_ferret handle this? Thanks
2006 Jan 09
1
Saving an upload
I am creating a database for movies (films) and television shows (shows) that will have has_and_belongs_to_many relationships with the pictures table. CREATE TABLE screenshots ( id serial NOT NULL, filename character varying NOT NULL, content_type character varying NOT NULL, primary key (id) ); CREATE TABLE films ( id serial NOT NULL, name character varying NOT NULL,
2005 May 23
1
has_and_belongs_to_many dual insert error ?
Hi ! (See references at the end) I have a slight problem. Whenever I save one of my domain models, which contains an has_and_belongs_to_many relationship with another one, the relationships are doubled. My domain is a series of pictures, where each picture can be tagged with one or more words. So, a picture of my dog could be tagged "Jordy, Dog, Dog 2005", for example. In my
2006 Nov 08
0
Prevent an object from being destroyed in HABTM relationship
Hello all, I have the following models: class Sku < ActiveRecord::Base has_and_belongs_to_many :options end class Option < ActiveRecord::Base has_and_belongs_to_many :skus end By default if I destroy an Option any relationships between Options and Skus will be removed as well. But, I want to prevent an Option from being destroyed when it is associated with a Sku in the options_skus
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.
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?
2009 Jan 25
1
habtm relation and dependent => :destroy
Hi all , I have a habtm relation between 2 tables: - users - rights If there a way to affect a destroy dependance on those 2 tables only for the last instance? In my opinion, dependent => :destroy is not the solution because this delete all the linked instance. For example, if I have: # in User model this: - "Joooooo" - "Jeannnn" - "Tommmm" # in Right
2006 May 18
1
HABTM destroy works in console, not in web browser.
In console I can set image = Image.find(id) and then do image.destroy and it works fine. It even cleans up the HABTM relationships thanks to a before_destroy method. The problem is though that when I try and do the same thing in my web browser, either in my view or via the URL scheme of /controller/destroy/id it gives me a "stack level too deep" error. Anybody know why it would work
2006 Jun 09
1
Updating Fields In Migration for HABTM Relationship
Earlier I forgot to add updated_at and created_at columns for my HABTM relationship so I created a migration to add them. In the migration I also want to go back and set the value of the created_at and updated_at columns for the previous rows. What is the best way to do that? Initially I thought I was being smart and decided to put an UPDATE SQL query in a find_by_sql statement and
2006 Apr 17
1
HABTM relationship with two join tables
Ok, I have a People table, a Shows table, a Techs table, and a Castmembers table. The people table has contact info about each person, the techs and castmembers tables have information about the persons specific role in that sshow. i want to call @show.techs (or somethign equivelent, I don''t want to start that code yet) and get all the techs associated with the show, and the
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
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
2006 Jun 10
0
Ordering Based on created_at in HABTM relationship
I have the following line in my controller: @tag = Tag.find_by_name @params[:id] Now, how do I order the rows based on the HABTM relationship problems_tags i.e. problems_tags.created_at DESC Thanks :-) John Kopanas http://www.kopanas.com ============================================================ http://www.soen.info - Index of online software engineering knowledge http://www.cusec.net -
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.
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
2005 Aug 30
0
question on HABTM relationship
Hi all. I have 2 tables, one is work_times, and one is projects. I use a joint table to link 2 as they are has and belongs to many relationship . so there is a project_work_time. Now I need to add one column ''work_hours'' that is unique to each row of joint table project_work_time. I need to make a view such that for one specific work_time, it lists a series of projects and
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
2006 Aug 22
0
Re: Problem with find condition and habtm relationship.
OK. This may help, but it will also make your head hurt. The basic problem that you''re running into is that you want a "for all" operator and sql doesn''t have one. Instead, you have to think of the query in terms of the logically equivalent "not exists not". Effectively, a proposition is true for all x if you can''t find a counter-example in
2012 Nov 03
0
ids writer fields for HABTM relationship.
Hello forum readers, Let''s say i have two models: Person and Role (i replicated the problem with Post & Tag as well, as i thought the problem was linked to some application-specific rights problem, but it wasn''t). In Person, attr_accessible role_ids is declared, so it accepts an array of Role ids as an argument when creating / updating. If i fire up the rails console and