similar to: Understanding :dependent => :delete_all?

Displaying 20 results from an estimated 10000 matches similar to: "Understanding :dependent => :delete_all?"

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 Dec 27
0
HABTM Checkboxes - Adding/Updating Users to a Project
Hello all, I''m trying to create a HABTM checkbox action that adds/updates ''users'' to a ''project''. I have the following laid out. --------------------- TABLES --------------------- create_table "assignments", :id => false, :force => true do |t| t.column "project_id", :integer, :default => 0, :null => false
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
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
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...
2010 Nov 24
0
Surprise in (delete_all | clear | destroy_all) on association
Hi, I was very surprised by difference of delete_all on association vs model(delegated to relation). Given TaskFilter.has_many(:qualifiers, :class_name=>''TaskFilterQualifier'') TaskFilter.delete_all => one DELETE statement Without :dependent option on "qualifiers" association TaskFilter.first.qualifiers.delete_all => SELECT `task_filter_qualifiers`.* FROM
2008 Feb 15
3
Destroy, dependent and performance
Hi! This is my first post in this forum. I''m learning RoR for two weeks and I''m very interested about how to improve this framework. I was testing one app I''m working in and I had some problems with destroying. The code is simple (and maybe wrong, as I said i''m just learning!). When you destroy a league, you send a message to all the users associated to this
2006 Jun 13
0
question about saving associations when using has_many :through
I''ve got a User model and a Book model. A user is required to submit books each month to be reviewed by other users. I have the following relationships defined: # the join model book_review.rb belongs_to :user belongs_to :book end book.rb # each book is reviewed by many users. This allows us to get the BookReview # objects associated with this book has_many :book_reviews,
2012 Jun 30
5
Problems with associations
Hello guys, I have two tables, tasks and projects, and each model I put: Task.rb class Task < ActiveRecord::Base attr_accessible :user_id, :project_id, :name belongs_to :project end Project.rb class Project < ActiveRecord::Base attr_accessible :name, :description has_many :tasks end But when I go to my prompt and I make a SELECT with task, none project is returned.
2008 Oct 16
1
merge/combine data
Hi, I have the following data imported from a csv file user_id site_id name 1 1 11 februari 2 1 11 redbook 3 1 11 tips 7 3 6 sleep 8 3 6 monitoring 9 3 6 alarm Which I would like to merge/combine into user_id site_id name 1 1 11 februari,
2010 Jul 11
10
dependent support for has_many through?
Given the following class Programmer < ActiveRecord::Base has_many :assignments has_many :projects, :through => :assignments end if I call Programmer#projects.clear, it will delete_all the joining assignments; however, I have a situation where I''d like the assignments to get destroyed instead so that their after_destroy callbacks get called. It would be simple to
2007 Jan 25
1
has_and_belongs_to won't delete records
Hi, I have a has_and_belongs_to relationship between 2 objects, order and product. I''m getting a foreign key violation when trying to delete Order. Is there a special way of deleting orders without deleting products? ("has_many" has :dependant => :delete_all.... does "has_and_belongs_to" have something similar) Trying: Order.delete_all Getting: Mysql::Error:
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
2006 Jan 30
1
Multiple associations between tables - do they ever work?
This is really bugging me. How can I get a second association to work between 2 tables. I have two models, User and Article. A user has many articles, and an article belongs to one user. Then I have the "current article", which is a the article that the user is currently viewing/editing. I want to track/save this value, so they can come back to the same article if they log out
2006 Jan 06
1
has_many with :finder_sql question
hi all, I have a Class, Client, which has_many projects (Project class). the projects depend on a session_id variable, however. So the question is, how can I do the following: has_many :projects, :finder_sql => "SELECT p.* FROM projects p INNER JOIN projects_users pu ON pu.project_id = p.id WHERE pu.user_id = #{session[:user_id]}" The problem is that I need to filter a
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 Jan 16
0
belongs_to with has_and_belongs_to_many
I''m having a problem with belongs_to and has_and_belongs_to_many. Here''s a brief summary of the models involved: class Member < ActiveRecord::Base set_primary_key ''member_id'' has_and_belongs_to_many :projects, :join_table => ''projects__members'' has_many :projects, :foreign_key => ''created_by'' end class
2007 Jun 07
4
checking associated objects have been deleted
I have the following model: class Book < ActiveRecord::Base has_many :taggings, :dependent => :delete_all has_many :tags, :through => :taggings end is it possible to check that associated taggings are being destroyed using mocks? I don''t want to test that rails is deleting the associations, I want to test that I have specified the association as a dependent one. the only
2007 Jun 04
1
acts_as_rateable in Beast
I''m trying to implement acts_as_rateable to my Beast installation to give users the option to rate posts (like reddit). I chose acts_as_rateable as it supposedly easily allows reddit-type voting but I''m having some problems setting it up and the documentation seems outdated. (http://www.juixe.com/techknow/index.php/2006/07/05/acts-as-rateable-plugin/) So far, I''ve
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