similar to: has_and_belongs_to won't delete records

Displaying 20 results from an estimated 9000 matches similar to: "has_and_belongs_to won't delete records"

2010 May 31
2
has_many and has_and_belongs_to conflit
Hi, I have 2 models: User and Article. I have this relationship: * User has many articles (and Article belongs to user) * User has and belongs to many articles (and Article habtm users) But this is tricky because of: current_user.articles ...this can return articles thanks to *has_many* and *has_and_belongs_to* relations. So there''s a collision. How can I ask articles thanks
2006 Aug 08
12
delete_if doesn''t work for has_and_belongs_to_many
I''m using Rails-1.1.4 with Ruby-1.8.4 So let''s say I have 2 model classes: class Item has_and_belongs_to_many :things end class Thing has_and_belongs_to_many :items end i = Item.new i.things << Thing.new( :value => "Something").save i.things << Thing.new( :value => "Something Else" ).save i.save Fine, now I have two records in the
2006 Mar 22
10
Need for multiple acts_as_list
I have a model "Childmodel" that belongs_to two other models "Parent1" and "Parent2". "Parent1" "has_many :childmodels, :order => :positionp1" and "Parent2" "has_many :childmodels, :order => :positionp2". i.e. The child is independently positioned within each of its parents. This works fine and gets me the useful
2007 Jan 14
3
Podcast API?
Hi, I''m looking into developing an API for publishing videso/audio/etc to iTunes using Rails. Has anyone done anything like this? or can point me in the right direction? The web doesn''t seem to have anything on it, regarding Rails or other technologies. Thanks --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the
2006 Mar 27
3
act_as_paranoid and model references
I''m using act_as_paranoid plugin for most of my models. One of the reasons was that I didn''t want to break references between objects after I "deleted" an object. One of the cases was to know which user modified something even after I deleted the user. My problem now is that I cannot access the user after it was deleted if I use the :has_and_belongs_to :user
2007 Jan 08
3
Relating Tables
I have 2 mysql tables, Product and Color: Color ID ColorName 1 Red 2 Green 3 Yellow 4 Blue Products ID Color1 Color2 Color3 ProductName 1 ? ? ? Orco 2 ? ? ? Skeletor 3 ? ? ? He-Man I need to display the ColorName to
2006 Jan 04
3
ActiveRecord delete_all With Sanitized Parameters?
Hi there I''m trying to delete a set of active record objects based on certain conditions. I''d like to do something like the following: Context.delete_all("uri IN (?)", uris) But delete_all doesn''t allow multiple arguments. Since I don''t have the IDs for the objects I want to delete, I can''t use delete(id), and have resorted to this,
2006 Mar 29
2
delete_all not resetting auto incement in database
Hey I''m writing a simple admin interface thats reading user data (skills) from a comma separated file. To clear the database before inserting new skills, I use Skill.delete_all Then I insert the new values I read from a file. Everything goes well up to the point where I see that auto-generated ID''s are not starting from 1. They start off at 840 (responding to the number of
2008 Apr 24
3
how to delete all document from the DB (without deleting the DB itself)
Hello, I'm still testing PHP5 bindings and I could'nt find a way to delete all documents from a DB without deleting other informations stored in the DB such as synonyms. Since the process of adding synonyms is time consuming, I would like to use the same DB but restart my test without any document in the DB, is this possibile? I could'nt find a delete_all or a method like that, nor
2008 May 28
2
functional testing joins table problem
I have models/controllers Class Facility has_many :facilities_services, :dependent => :delete_all Class Service has_many :facilities_services, :dependent => :delete_all Class FacilitiesServices belongs_to :facility belongs_to :service so in my test/functional/facilities_controller_test.rb, I have post :destroy, :id => 5 which tosses an error...
2009 Oct 20
2
Find sub sub records
Hi everyone, I have the following problem, maybe someone can help me figure out what to do. To simplify my situation, I''m going to make an example of what I need, this is not the real app structure. Let''s suppose we have three models, Library, Author, Book. Manager has_and_belongs_to_many :area_managers AreaManager has_and_belongs_to_many :managers has_many :employees
2006 Jul 26
7
Delete_all causes a deadlock on MSSQL database ???
Hi all, When i use the ''delete_all'' function to remove a few rows from my database, it causes a deadlock on the sql server. The delete seems to be successful, it then redirects to the ''view'' page, and the record does appear to be deleted as far as the ''view'' rails page shows. BUT if i go into sql query analyser, i can''t do a
2005 Dec 15
3
How to delete a record
hey, i my database i have users and groups, each user can get in different groups my db structure: table groups: id, name, basegroup, firm_id table users: id, firstname, lastname, email table groups_users: group_id, user_id my relation is a many to many: class Group < ActiveRecord::Base has_and_belongs_to_many :users end class User < ActiveRecord::Base has_and_belongs_to_many
2006 May 06
3
Question about one-to-many-to-many
Guys, I''ve set up a 1-M-M relationship between 3 tables/models. I can''t get cascading deletes (haven''t tried updates yet) to work when the master record is deleted. I''m using MySQL 4.1.x, and the error message is: Mysql::Error: #23000Cannot delete or update a parent row: a foreign key constraint fails: DELETE FROM contact_addresses WHERE (contact_id = 1).
2006 Aug 16
1
Naming rights_roles join model using has_many :through and polymorphic associations
Hi. I have a couple of best practices questions regarding polymorphic associations, naming join tables and user permissions. Currently I have implemented the user authentication model from the rails recipes book. Basically it goes something like this: MODEL CLASSES: class User < ActiveRecord::Base has_and_belongs_to_many :roles end class Role < ActiveRecord::Base
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 06
6
HABTM problem not saving all associations
Hello all, I have an Order object that has and belongs to many Products and has and belongs to many Loan Types. This is so I can select multiples of each in my order entry screen via checkbox groups. I''m having some trouble with saving multiple HABTM associations for a single model object; only the first HABTM association declared in the model will save during the initial @order.save
2006 Jul 10
3
Problem with migrations
I am trying to start my first project after going though the Depot application in prog prog''s book. For some reason one of my migrations keeps bombing. I just try to setup a couple tables with some default information and even with changing the name of the second table and other minor tweaks it just does not work. I am connected to the db, the first table does get filled out. Any help
2006 Sep 03
1
New Technique: Subsets of has_many Associations
I just now thought of this, and sure enough it works like a charm (at least so far in my limited testing): has_many :events, :dependent => :delete_all has_many :upcoming_events, :class_name => "Event", :conditions => "date > NOW()" The purpose of this is that it makes eager loading of subsets of associations possible without replacing all the magic of the
2012 Sep 12
2
how to generate third table in test database
hi all, has_and_belongs_to_many :cows has_and_belongs_to_many :milkmans i am using has_and_belongs_to_many in my app.I know this will create third table internally cows_milkmans in mysql database. when i migrate develpoment database i have table cows_milkmans. Good no Problem till now. Now a problem start When i migrate test database there is no such cows_milkmans table is present..