Displaying 20 results from an estimated 40000 matches similar to: "cancelling before_destroy"
2008 May 18
0
Spec a before_destroy callback in Sequel
Hi
I''m struggling to find a neat way to spec this. The Sequel ORM
doesn''t support automatically destroying dependent models. It''s easy
enough to do in a callback though:
class Changeset < Sequel::Model
has_many :migrations, :class => DataModel::Migration
before_destroy do
migrations.each { |m| m.destroy }
end
# ...
end
2008 Jul 02
2
How to write the method before_destroy and the test
How to write the method before_destroy?
Here is my code:
def before_destroy
errors.add(:isdefault,"Can''t destroy default record") if
self.isdefault
return false
end
or I should write it like below?
def before_destroy
raise(Can''t destroy default record") if self.isdefault
end
and how to write the test for it
--
Posted via
2006 Mar 24
2
before_destroy not called
Hello, I''m trying to intercept delete call in my model but
before_destroy callback is never called...
Somebody knows why ?
Thanks
The controller :
def delete
Image.delete(params[:id])
redirect_to :action => "list"
end
The model :
class Image < ActiveRecord::Base
set_table_name "publish_images"
belongs_to :article
before_destroy :on_destroy
2007 Mar 14
0
before_destroy return false, but dependent are destroyed
I have a problem with before_destroy deleting by dependent records,
even through I return flase.
...
has_many :users, :class_name => ''Editor'', :as => :editable,
:dependent => :destroy
...
def before_destroy
unless self.has_access?(99)
errors.add_to_base "Destroy permissions error!"
return false
end
end
When I remove the dependent
2006 Nov 17
4
before_destroy and sessions
(Semi-newbie.) I want to ensure a user''s able to destroy only his own
objects. I''ve set session info at login:
session[:user_id] = user.id
Now I try this in the model of my deletable objects:
before_destroy :destroy_your_own
def destroy_your_own
raise "Can''t delete that!" unless session[:user_id] == self.user.id
end
which snags EVERY attempted
2010 Mar 24
1
How to stub a has_many relationship in Rails 2.3.5
We have a test that has been working find until we upgraded to rails 2.3.5.
I''m not too familiar with mocks/stubs so maybe there is an easy solution.
Here is a simple example of our scenario.
Class Person < ActiveRecord::Base
has_many :aliases, :dependent => :nullify
before_destroy :mark_aliases_as_deleted
def mark_aliases_as_deleted
self.aliases.each do
2006 Jun 29
1
before_destroy & verification
Hey, probably an easy question but,
I''m trying to get a method to run "before_destory" for a model, and I
want the method to throw an error, and not delete the object from the
database, if a certain condition is held
Obviously, I can just raise an error and rescue it... but for some
reason I can''t get <% error_messages_for ''model" %> to catch
2006 Jan 31
0
About echo cancelling
There were little changes when I activate "echo cancel" without AGC.
And activating "echo cancel" with AGC results poor voice quality.
The relationship between input frame and echo frame is written to "very important" in SpeeX 1.1.11.1 manual.
And I use "previous decoded data" for echo frame. <<<<---- no problem???
I show you again my code
2006 Jan 25
1
About echo cancelling
Hi.
I've implemented "echo cancel" to voip project.
But it doesn't work well . (I cannot feel the enhancement with activated AGC)
My encode settings :
1. frame size : 320 bytes.
2. sampling rate : 16000 Hz (WB)
3. mono
echo state initialized like this :
echo_state = speex_echo_state_init(framesize, framesize*16);
and befor encode :
speex_echo_cancel(echo_state,
2006 Jun 06
0
Problem in cancelling print-jobs in cups-samba
Hi All,
I have managed to integrate SAMBA and CUPS on my hardware running on linux basically used as a print-server. I give print-commands from Windows PC and the printer is connected to the hardware.
I am able to get the print-jobs done.
Also, I am able to cancel all the jobs at a time by selecting "Cancel All" from the menu
The problem is that I am unable to control the individual
2007 Mar 06
1
Cancelling a digit in IVR
Hello,
I'm wondering how to make it possible for the user to cancel the last
entered digit, if he made a mistake.
For example, a user calls and starts entering 1...2...4, then he should
be able to press, lets say *, to cancel 4 and enter i.e. 3.
Thanks
Jake
--
------- Domeny w ULTRA NISKICH cenach: -------
.pl - 29 zl, .com.pl - 22,50 zl, reg - 7,50 zl
2005 Dec 29
5
Extracting SQL and Rebuilding from SQL?
Hello-
With a database filled with several customers'' datasets, I thought it
would be a nice feature of my app''s backend interface to be able to
extract (and optionally delete) the data from a single customer. It
would then also be nice to rebuild that data from the stored info.
What''s a good way to do this efficiently?
If all the ":dependent => true"
2005 Dec 22
1
How to write unit tests with respect to model callbacks?
Hello,
I am exploring the "Testing" part of Rails, but It seems some things
work differently than I thought it would.
Consider the following model:
class Client < ActiveRecord::Base
has_one :project
def after_create
Project.new(:name => self.name, :is_client => true, :client_id
=> self.id).save
end
def after_update
2007 Jun 29
1
Speeding up :dependent => :destroy
I have a tree of models that represent a book. Looks like this:
book
sections
documents
paragraphs
index entries
glossary entries
footnotes
index entries
glossary entries
These are all models with has_many from parent and the child has
belongs_to. They also all have dependent => :destroy
2009 Oct 14
0
[PATCH server] hack betternested set to enable pool deletion
This is an ugly hack to fix the betternestedset plugin as currently
a bug does not allow pools to be deleted. The single line commented
out in this patch deletes the pool itself instead of only its children
for whatever reason.
This wouldn't be a problem were it not for the recent
change to active record which enforces optimistic locking upon
destroy operations. Since the database record is
2008 Sep 07
1
Echo cancelling results
Hi,
I wanted to play around with the echo canceller so I tried the testecho
program.
As speaker sound I fed it with a 440 Hz sine wave, and as mic with a 550
Hz + 440 Hz sine waves sound (but the 440 Hz component half the amplitude).
I kind of expected to get a somewhat clean 550 Hz sine out, but it
doesn't seem to work that way.
Are there better samples I can use with testecho to see
2007 Mar 06
0
:dependent => :destroy_unconditionally?
Hey...
I have these business_accounts that have a bunch of members through a
business_account_membership model. A membership can be a privileged,
"managing" one, and a business account should always have one such
privileged member, so I have a before_destroy filter on the
business_account_membership model to prevent the deletion of the last
managing member of a business account.
2006 Dec 07
2
validate_on_destroy ?
What''s the best way to validate_on_destroy. Rails only seems to include
validate_on_create and validate_on_update methods. I don''t want to
resort to doing:
before_destroy do |j|
raise "There is an error" if j.etc
end
Is there a way of finding out what action (create/update/destroy) is
being performed if I use the ''validate'' method?
--
Posted via
2008 Mar 17
4
RSpec''ing model association callbacks
Hi all,
i''m learning rspec and i must admit i really love it.
But at the time i started learning it, i already
developed my models classes and their callbacks.
Now i''m trying to get a 100% coverage of my code but i
cannot reach it because i do not understand how to
spec my callbacks.
Look at this for example:
----------------- User Model
class User < ActiveRecord::Base
2009 Apr 02
3
error_messages_for does not display the error
Hi all
I''ve approached Rails since a couple of months to develop a quick
application for my company. Fantastic framework. As every noob, I do
have some gaps to cover. The one which is giving me a little
frustration, generated by my lack of knowledge is as follows.
I need to make sure the region object is not deleted if there are
countries associated with it. I solved this by putting a