similar to: after_update and increment!

Displaying 20 results from an estimated 2000 matches similar to: "after_update and increment!"

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 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 =
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''
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 Jan 25
1
cache_sweeper causes undefined method error
I created a sweeper ItemSweeper and saved it in app/models/item_sweeper.rb. Then I put this in my item_controller.rb: cache_sweeper :item_sweeper, :only => [:create, :destroy, :update] But now when I call the view action, I get this error: ActionView::TemplateError (undefined method `title'' for nil:NilClass) on line #5 of app/views/item/view.rhtml: 5: <H1
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 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
2009 Mar 29
2
after_create and after_save
Hi, AFAIK after_create is called after_save if the entry does not exist in the DB. Is there a way to tell if a specific model is new or not in after_save? I have to do something like: def after_save add_to_history ''save'' end def after_create add_to_history ''create'' end However after_save is called when creating too. -- cheers, M.
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 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
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 Sep 10
2
expire_page not working
I''ve enabled page caching on a site I''m currently constructing. The sweeper is called upon any changes made to the model, as expected. The sweeper code is as follows: class PersonSweeper < ActionController::Caching::Sweeper observe Person def after_update(person) expire_staff_page end def after_destroy(person) expire_staff_page end def
2008 Mar 06
3
cache_sweeper
Hi, Why is cache_sweeper not a documented method? I was pretty sure it used to be, but I could be wrong. I can''t seem to find any information on it anymore in the online docs. As a side note, looking at the code for cache_sweeper it appears to only work with the :only option, not :except (ignores it)... what''s the reason for this? Thanks, Andrew
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
2006 Jul 18
7
Observer not working
Help please. I''m trying to observe a User class, but I can''t get this to work, the after_create method never gets called... (the breakpoint never gets called) app/models/user_observer.rb: class UserObserver < ActiveRecord::Observer def after_create(user) breakpoint setting =
2008 Jul 21
1
Re: Observer
eh, like so? def after_create(model) generate_hotel_param_files(model.id) generate_hotel_setup_files(model.id) end def after_update(model) generate_hotel_param_files(model.id) generate_hotel_setup_files(model.id) end On Jul 21, 9:59 am, David Nguyen <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote: > Hi, > I have to make an observer if a
2006 May 24
1
Observer behavior differences between DEV and TEST environments ?
Hi all ! I''m having an issue and I can''t seem to make heads or tails of it. I am attempting to add an observer to a model object. I created app/models/greenback_transaction_observer.rb, inherited from AR::Observer, defined methods, registered in config/environment.rb, but things don''t work... So, I took a step back and put in the following code: class
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 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
2007 Oct 24
0
Sweeper for few models
For example - i have a sweeper for one model(in this case About). class AboutSweeper < ActionController::Caching::Sweeper observe About def after_create(data) expire_about(data) end def after_save(data) expire_about(data) end def after_destroy(data) expire_about(data) end def expire_about(data) FileUtils.rm_rf