Displaying 20 results from an estimated 11000 matches similar to: "how to disable callback"
2006 May 31
0
restrict callback to fields
please can some kind soul point me to the right track.
how can I express:
"do something when any field of this class is updated except field X"
I need to do anything that would behave like
after_update :do_something #unless the updated field is field X
that is: after_update is called every time a set_ method is called,
except set_x
Is that at all possible?
Isabelle
--
Posted
2006 May 10
8
dynamic setting of username and password in database.yml
Hello
I''ve now read a lot about application-level authentication in Rails, but
I need to do database-level authentication.
The reason is that my database needs to have the current_user (database
current_user, not current_user defined in an ActiveRecord Model) set to
execute triggers for automatically updating audit tables. So it is not
enough to have a session check against a User
2006 Jun 01
4
how can I control when to commit a transaction?
hello
it seems like this question has appeared a few times with no answer:
how do you get rails to issue ''write'' statements (ie ''CREATE/UPDATE'') to
the database without committing each time?
I tried setting
ActiveRecord::Base.connection.begin_db_transaction
before calling any action on my object, but as soon as
myObject.save
or
myObject.update
is called,
2006 Apr 07
2
errors.add_to_base
What are the limitations on using:
errors.add_to_base
to display errors in views?
I have tried for days to add errors from my object.rb and they never get
displayed.
class Keyword < ActiveRecord::Base
validates_presence_of(:name, :message => "Name is required.")
validates_uniqueness_of(:name, :message => "This name is already in
use. Please try
2006 Jun 01
4
Ruby on Rails strange issue
Hello,
I just installed Ruby on Rails and created the new repository.
I wanted to use Ruby on Rails with FCGI
The repository was created in /path/to/public_html
ls /path/to/public_html/ :
app cgi-bin config doc log public README script
tmp
asd components db lib logo.jpg Rakefile README_LOGIN test
vendor
I installed fcgi support for ruby on rails and
2006 Aug 10
6
save without commit ?
How do I get ''save'' to execute without commit?
I have tried:
ActiveRecord::Base.connection.begin_db_transaction
# do some stuff that doesn''t issue a database COMMIT statement
# then:
@myObject.save
# this issues a COMMIT but it shouldn''t! Shouldn''t it wait until I''ve
called:
ActiveRecord::Base.connection.commit_db_transaction
?
what am
2006 Jun 01
2
update_all broken in postgres?
Hi
has anyone managed to use update_all with rails on postgres?
In my setup, it does not work:
>> @keyword.update_all(myupdates)
NoMethodError: undefined method `update_all'' for #<Keyword:0xb7ac4670>
from
/home/lib/ruby/gems/1.8/gems/activerecord-1.14.0/lib/active_record/base.rb:1786:in
`method_missing''
from (irb):14
I checked that the base.rb
2006 Feb 22
0
How to get model observer to work?
I can''t seem to get a model observer to work. In my environment.rb I
have:
config.active_record.observers = :item_observer
In item_observer.rb I have:
class ItemObserver < ActiveRecord::Observer
observe Item
def after_update(item)
if @old.active != item.active
logger.debug ''observer#after_update''
#...
end
@old = nil
end
def
2007 Sep 21
1
Temporary disabling after_update
Hi,
I am trying to replace my old database trigger with ActiveRecord
callbacks in rails.
I have a model like following:
class Action < ActiveRecord::Base
belongs_to :inquiry
def after_update
#clean up all action associated with the inquiry.
Action.update_all("latest = ''''", ["inquiry_id = ?",
self.inquiry_id])
#find the latest action
2006 Feb 19
0
newbe: observer setup
Hi All,
Having problem setting up an observer to log changes to
a database. I have following the Prag Rails book but think
I have something missing. I am trying a simple puts to see
if the observer is working, but getting nothing on the console.
Here is what I have. I don''t get any errors.
Thanks for any suggestions/references to debugging.
Dave
The two models:
display_ad.rd
2004 Feb 25
1
probleb with 'passwd chat' and 'passwd program'
Hi !
I have a problem using an external script to change password :
in smb.conf, i have :
=> passwd chat = "Changing password for*\nNew password*" %n\n "\nRetype
new password*" %n\n
=> passwd chat debug = Yes
=> log level = 100
=> unix password sync = Yes
=> passwd program = /usr/local/sbin/smbldap-passwd %u
The script is called normally, and logs show that the
2006 Mar 08
3
Namespace & Organisation Conventions
Hi All
I wanted a little advice on the convention for namespace usage and
organisation of code.
I originally used PHP and often had an "admin" backend that performed the
various admin tasks with users, and data
Then I had a front-end often situated at the root that had user services.
I''m trying to emulate this in Rails but feel I''m missing a significant point
here and
2007 Mar 09
1
in after_update, possible to see previous value of record?
I have this situation where in an after_update, I would like to know
the previous value of the record instead of simply being notified the
record has been updated.
For example let''s say I had a table called ''foo'' which had a field
''new_flag''. I want to know when the ''new_flag'' field changes from 0 --
> 1 in an after_update so I
2006 Jun 01
0
question about observer callbacks
I''m not sure how to implement this so I''ll describe what I currently have
done then what I wish to have happen
currently, I have a generic observer for several models
class AuditObserver < ActiveRecord::Observer
observe Foo, Bar
def after_update(model)
model.log("UPDATED " + Time.now.strftime("%m-%d-%Y %H:%M"))
end
def after_create(model)
2006 Mar 30
0
Specify callbacks before associations
In the RoR API documentation
(http://api.rubyonrails.org/classes/ActiveRecord/Callbacks.html) for
callbacks, there is a note that says:
"*IMPORTANT:* In order for inheritance to work for the callback queues,
you must specify the callbacks before specifying the associations.
Otherwise, you might trigger the loading of a child before the parent
has registered the callbacks and they won?t
2006 Apr 05
4
validation on before_add callback
problem: validation error is not functionning in callback
callback for many-to-many association:
# keyword.rb
:before_add => :reject_self_related
def reject_self_related(related_keyword)
if (related_keyword == self)
# this does not work:
errors.add(:name, "Relating a keyword to itself is
forbidden!")
raise "Relating a keyword to itself is
2001 Aug 21
0
Re: [R] Problem using GLM in a loop (fwd)
This example is caused by R's messing with formula environments.
That's explained in ?formula, but should it not be explained in
?model.frame ?
Simple test:
data <- data.frame(y=rnorm(100), x=1:100)
testit <- function(formula)
{
weights <- runif(100)
glm(formula, weights=weights, data=data)
}
testit(y ~ x)
weights is looked for in the environment of the formula, not of
2006 Feb 22
5
Auditing mixin for model classes. Small problem
I want to include common auditing functionality in my models. This
involves storing the changes made to a model in a seperate table :
I have created the functions in an Audit module :
module Audit
before_update :before_changes
after_update :after_changes
def before_changes
old=self.class.find(id).attributes
@changes=[]
attributes.each do |key, val|
if val != old[key]
2000 Oct 26
2
Problem with lm
Hello Everybody,
I have a problem with the output of lm.
In fact, when I compare the R output and the Splus output, the results
appears to be different :
I have a dataframe with 5 factors , 16 rows and a response.
First, I tried to fit this response to a linear model :
lm(rep~(A+B+C+D+E),data).
The results beetween SPlus and R are different.
In a second time, I tried a new fit :
2007 Jan 04
6
after_update attributes problem
Hey guys,
I''m having a hard time w/ the after_update callback on rails... As
far as I can tell, when I define a after_update callback on a model,
the attributes of the object have the same values that they had
*before* Base.save was called. I''m probably wrong so here''s the code:
UNIT TEST:
def test_register_item_adjusts_account_balance
account =