search for: before_validation_on_upd

Displaying 6 results from an estimated 6 matches for "before_validation_on_upd".

2006 May 30
1
Read-Only Model Attributes AFTER creation?
...form to change your username. I know I could use attr_protected on username, but that would still allow for usernames to be changed (abeit not through the form). How can I make the username read only AFTER the object has been created? Is attr_reader what I need? I thought about doing it with before_validation_on_update, but I''m not sure as to what the best method of determining what the ''true'' username is to compare it to the one that the model has now. Would username = User.find_by_id(id).username be The Right Way to do this in the callback? Thanks! - Nick Evans
2006 Mar 23
1
handle multiple lists: move an item from one list to another
How do I manage multiple lists? This is what I need. Sometimes an item needs to be moved from one list to another. class Item < ActiveRecord::Base belongs_to :group acts_as_list :scope => :group end class Group < ActiveRecord::Base has_many :items, :order => "position" end Now, sometimes, I may need to change an item from one group to another. But when I do that,
2006 May 24
1
Observer behavior differences between DEV and TEST environments ?
...following code: class GreenbackTransactionObserver < 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_...
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 Apr 01
3
acts_as_list with scope : position update problem?
...ethod, and I can''t figure out what''s wrong. class Person < ActiveRecord::Base belongs_to :family, :order => ''position'' acts_as_list :scope => ''family_id'' validates_uniqueness_of :position, :scope => ''family_id'' before_validation_on_update :reorder_positions private def reorder_positions @updated_family_id = params[:person][:family_id] unless @updated_family_id == self.family_id self.move_to_bottom # reorder original list params[:person][:family_id] = Family.find_by_id(@updated_family_id).people.length + 1 end en...
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 =