search for: after_validation_on_upd

Displaying 9 results from an estimated 9 matches for "after_validation_on_upd".

2006 Jul 30
0
after_validation_on_update double invokes
Hello to all, I want to use the after_validation_on_update call back to keep some redundancy in sync with the model. But now I''ve encountered that the call-back get called two times. Is this the intended behaviour? What can I do to prevent Rails from doing so? best regards Torsten
2006 May 08
6
how to make field in model immutable after create
Hello everyone! I want to have login field in User model which is set only once (on create), and then it should fail validation if the value is changed. How can I do this? I dig around for validation and tried def after_validation_on_update unless User.find_by_login(:login) errors.add(:login, "is immutable. You can''t change it") end end in model, but somewhat it doesn''t work. Any hints on how can I make field immutable after create? Peace, olegf
2008 Feb 03
1
ActiveRecord object.valid? triggers unexepected results
...;'m editing an ActiveRecord object in a session through AJAX, updating it with object.attributes = params[:object], and validating it with object.valid? Because it''s associated with other objects in a form, I want to save them all together. The surprise was that object.valid? triggers after_validation_on_update. I''m having an audit log and I was getting bogus entries. http://api.rubyonrails.org/classes/ActiveRecord/Validations.html#M001316 valid?() Runs validate and validate_on_create or validate_on_update and returns true if no errors were added otherwise false. valid?() should run all vali...
2006 May 21
0
expiring cache fragments using script/runner
...to expire some of fragments on an hourly basis. I was going to use cron and script/runner to do this. For other fragments that I am expiring, I am using expire_fragment inside a sweeper class, something like: class QuestionSweeper < ActionController::Caching::Sweeper observe Question def after_validation_on_update(question) expire_page :controller => ''xml'', :action => ''question'', :id => question.id expire_all_recently_added end ........ def expire_all_recently_added expire_fragment :controller => ''landing'', :action => ...
2010 Aug 14
0
How do I unit test this?
I''ve got a cache sweeper running observing a model "after_validation_on_update". Inside that filter method, a call to "controller.current_user" is made to access that application_controller method (to get the current user in session). I get the error "NoMethodError: undefined method `current_user'' for nil:NilClass" when running my unit t...
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 May 24
1
Observer behavior differences between DEV and TEST environments ?
...nbackTransactionObserver < ActiveRecord::Observer %w( after_find after_initialize before_save after_save before_create after_create before_update after_update before_validation after_validation before_validation_on_create after_validation_on_create before_validation_on_update after_validation_on_update before_destroy after_destroy ).each do |method| define_method(method) do |txn| txn.logger.info "#{method} (observer)" true end end end My model looks like this: class GreenbackTransaction < ActiveRecord::Base %w(before_save after_save).each do |method|...
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 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 =