Displaying 20 results from an estimated 400 matches similar to: "Temporary disabling after_update"
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
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 =
2007 Feb 09
1
after_update and increment!
I''ve got a strange behaviour that didn''t seem to be happening before I
upgraded to 1.2.
I''ve got two models - questions and results.
When a user answers a question, his answer is recorded in results. In
my results model, I have an after_create that increments! a count in
the question model.
This increment is now triggering an after_update method I have in a
2006 Feb 22
3
after_update: old, new values?
With after triggers in Postgres, there are special NEW and OLD vars
accessible to trigger functions. Any such thing in Rails? Or would it
entail doing something like setting a class var in before_update?
Jack
--
Posted via http://www.ruby-forum.com/.
2006 Jul 19
0
save without after_save, after_create, after_update?
How to update attribute(s) and save a record instance without triggering
the hooks: after_save, after_create, after_update?
I know it''s possible with Record.update() but this is dynamic. Only
receive the instance, without knowing its class (thus cannot call the
class method update()). Or is there a way of knowing the class and
calling the class method?
Thank you.
--
Posted via
2010 Sep 22
0
after_update should not be called
Hello,
consider this code: http://pastie.org/1173871
Why after_update in Subscription model gets called?
I''m using Rails 3.
Thanks
--
Posted via http://www.ruby-forum.com/.
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to
2012 Dec 06
2
Bye Bye, Observers
Observers will be no more as of Rails 4, farewell, never been much of a
fan. However, I''m using it in one of my gems which enables model attributes
for use with a WYSIWYM editor. The resulting markup is persisted, but in
order to use it in a view, it has to be nokogiried in a helper which
fragment caches the result. This cache has to be zapped once the model
instance is either
2009 Jun 27
1
Problem with :touch in belongs_to
I''ve read in rails api that there is a touch parameter and I want to
use it in my application. I have something like that
class User < ActiveRecord::Base
has_many :phones
after_update :updated
def updated
...
end
end
class Phone < ActiveRecord::Base
belongs_to :user, :touch => true
end
I want that every change of any phone number would change User
updated_at
2006 Apr 06
7
LoginSystem : make @session available to models
Hello.
LoginSystem is cool, it populates the @session instance variable of
controllers with many useful info.
The fact is : it would be cool to let models know about the session,
too.
For instance, after_update and after_create callbacks could store *who*
did *what* on *what.
Aim : having ActiveRecord::Base::session defined, returning the @session
of the controller which manipulates the
2006 Mar 24
6
Should counter_cache fields be saved in the database?
As far as I can tell, the counter_cache option on a belongs_to model
doesn''t actually save anything in the database. For example, I have
the following models:
class Parent < ActiveRecord::Base
has_many :children,
:conditions => "deleted_at IS NULL"
end
class Child < ActiveRecord::Base
belongs_to :parent, :counter_cache => true
end
With the following
2006 Jul 05
2
Serialized object behaves weird
Hi!
I got a class named EinsatzFilter which I serialized to session. Before
saving to session it works afterwards I keep getting the message:
"undefined method `to_s'' for #<Person:0x38c6ab8>". "Person" is a from
ActiveRecord::Base inherited class.
Code:
class EinsatzFilter
include ApplicationHelper
attr_reader :personen, :monat, :projekte, :kunde
2007 Apr 05
2
best way to maintain dynamic fields?
I have a Topic that has_many comments. In the search results only want
Topics to show up, but I want them to include the text of the comments
that they have when they are indexed. To do this I''ve added a
:comments_text field for acts_as_ferret and the comments_text method
gathers the text from all comments up into a string that can be indexed.
The trick is that when comments are added,
2006 Sep 15
2
Caching::Sweeper Access to Controller
Hello,
I''m running Mongrel 0.3.13.3, cluster 0.2.0, and Rails 1.1.6 and I
have a problem with a sweeper not having access to the controller
instance.
NoMethodError (undefined method `session'' for nil:NilClass):
/app/models/audit_sweeper.rb:16:in `log''
/app/models/audit_sweeper.rb:9:in `after_update''
2007 Feb 14
4
cache sweeper not getting called
Hi,
I''ve started to implement page caches but I''ve hit a brick wall getting
a sweeper to clear the cache when needed. It seems that any models that
I tell it to observe aren''t being observed properly. If I add the
sweeper to a controller the initialize method runs, but no matter what I
do the after_save/after_update callbacks aren''t running. Also if I try
to
2007 Sep 07
3
Fails to restart mongrel cluster after Capistrano rollback (PIDs not deleted)
Hi,
I am deploying a Rails website using Capistrano to a VPS running the
site through Apache and Mongrel.
''cap deploy'' works fine, and mongrels are restarted. When I execute
''cap deploy:rollback'', however, my script fails to restart the
mongrels giving this error:
!!! PID file tmp/pids/mongrel.5000.pid already exists. Mongrel could
be running already.
2008 Jul 02
3
update_all not changing updated_at
Hi everyone-
Model.update_all works and changes the records, but it''s not changing
the updated_at field. Am I doing something wrong or is this by
design?
Thanks,
Dino
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to
2006 Oct 25
4
Search result inconsistencies due to indexing
I seem to be having problems with getting my searcher to be consistent
while indexing. I am running the latest version of ferret (0.10.13) and
I am using the Searchable plugin. Currently the way it indexes is by
using a callback in the model of either after_update or after_create to
index the fields that I have setup to be indexed.
Right now I update the index about once every 4 or 5
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
2007 Mar 29
1
How to restart server programmatically?
I need to be able to restart my server based on a specific database change.
I''ve been trying a call to system("script/process/reaper -a graceful -d
dispatch.fcgi") but that raises a transaction error which rolls back the
save. I wasn''t aware that after_save would rollback. That''s potentially
useful but pretty much not right now. Here''s my code:
def
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