search for: delete_all

Displaying 20 results from an estimated 104 matches for "delete_all".

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 =...
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, which is significantly slower since it has to instantiate each object, and ther...
2007 Aug 12
5
stubbing a method that yeilds sequential results
I''ve just found myself stuck trying to rspec something so am hoping someone more knowledgable can help. I have a Connector class which has a class method ''results'' that yields results it get from a network service based on a set of attributes that I pass to it. I am wanting to yield these results from my Intermediate class up to the next
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 skills times the number of times I reloaded data). From my log I can see that the SQL quer...
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...
2007 Jan 23
2
Understanding :dependent => :delete_all?
...39;s probably just because I''m so new to Rails! To get right into it... I have 4 tables that look like this: Sites - id Projects - id - site_id - user_id Tasks - id - project_id - user_id Users - id The corresponding models: class Site < ARB has_many :projects, :dependent => :delete_all end class Project < ARB belongs_to :site belongs_to :user has_many :tasks, :dependent => :delete_all end class Task < ARB belongs_to :project has_one :user end class User < ARB has_many :tasks end The idea is: 1. If you kill a site you kill all of its projects (this work...
2006 Jul 17
5
quantic phenomena in migrations
I have an application with 15 migrations under version control. In a Mac and and in a Windows, a rake migrate from scratch runs them all just fine. But in a different Windows machine rake migrate stops after migration 3 for no apparent reason. --trace seems normal. No error is reported. Both Windows are XP SP2. They all have the same svn revision and Rails-related software, database is
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 to deal with, destroy_all is very processor and time intensive. How best to quickly truncate one side of the hab...
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... test_destroy(FacilitiesControl...
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: #23000Cannot delete or update a parent row: a foreign key constraint fails: DELETE FROM orders With associations: class Order < ActiveRecord::Base has_and_belongs_to_many :produc...
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 way I can think...
2008 Apr 24
3
how to delete all document from the DB (without deleting the DB itself)
...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 an iterator over all documents without querying. Any idea? -- Alessandro Pasotti w3: www.itopen.it
2007 Sep 07
6
ActiveRecord::Base#update_all expected behaviour
Hi I noticed that if in my code I use the following: Photo.update_all("title = ''Ruby rocks'' ", "id IN (#{@photo_ids})") All my objects are properly updated but none of the filters/callbacks are triggered. Is that what''s expected? I have a before_update filter set on the Photo class and it gets totally ignored, I guess the only way to solve this
2006 May 17
0
teardown not cleaning the BD?
Hi, I am a bit confused, I have a few functionnal tests were I add/delete records on top of the ones provided in the fixture and it seems like the records are surviving the teardown. Isnt teardown supposed to be ran after each test? So if I have something like: def teardown Client.delete_all Concept.delete_all Variation.delete_all ClientVariation.delete_all end All the records from my DB should be deleted... Well, when I run my test, I get a faillure on a test that is supposed to make sure that a specific record is deleted. When I look at the DB, the record is still t...
2006 Jul 10
3
Problem with migrations
...e.create( :employee_number => ''1234'', :name => ''Bob B'', :location => ''Office'', :department => ''07'', :company_code => ''003'') end def self.down Employee.delete_all end end 003 class CreateCostCodes < ActiveRecord::Migration def self.up create_table :cost_codes do |t| t.column :job, :integer t.column :code, :integer t.column :description, :string end end def self.down drop_table :cost_codes end end This is the mig...
2007 Mar 09
5
higlighting problem
Hi, I''ve been having a problem getting highlighting to work with aaf. I have a class defined as follows such: class Link < ActiveRecord::Base acts_as_ferret :fields => { :description => { :store => :yes } } end I get back the correct results when I do Link.find_by_contents, however, I''d like to highlight them. If I do something like iterate through the list of
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 original association that you may want. If you consider tha...
2012 Nov 08
1
validates_uniqueness_of(*attr_names) w scope not working in unit test
...;) @coocoo = FactoryGirl.create(:subdomain, name: "coocoo") FactoryGirl.create(:user, subdomain_id: @booboo[:id], email: "user.doe-PV5Ro7/Mrj4@public.gmane.org", password: "UkZaHWcy", password_confirmation: "UkZaHWcy") end def teardown User.delete_all Subdomain.delete_all end test "should_save_user_with_duplicated_email_in_another_scoped_subdomain" do user = FactoryGirl.build(:user, subdomain_id: @coocoo[:id], email: "user.doe-PV5Ro7/Mrj4@public.gmane.org", password: "UkZaHWcy", password_confirmation:...
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
2007 Sep 24
3
Trouble using backgroundrb
...t. Here''s my code: -------------------- controller app/passwd/index -------------------- class Passwd::IndexController < ApplicationController layout ''default'' def index $subtitle = "AIX user inventory tool" end def createReport Passwdentry.delete_all User.delete_all session[:job_key] = MiddleMan.new_worker(:class => "passwd:get_passwds_worker", :args => "") end def get_progress if request.xhr? progress_percent = MiddleMan.get_worker(session[:job_key]).progress render :update do |page|...