search for: before_remov

Displaying 3 results from an estimated 3 matches for "before_remov".

Did you mean: before_remove
2010 Jul 12
1
How to turn :before_add exceptions into validation errors
As per http://rails.rubyonrails.org/classes/ActiveRecord/Associations/ClassMethods.html Possible callbacks are: before_add, after_add, before_remove and after_remove. Should any of the before_add callbacks throw an exception, the object does not get added to the collection. Same with the before_remove callbacks; if an exception is thrown the object doesn‘t get removed. However, when the add fails due to a before_add violation, the exception...
2006 Jun 23
0
adding action after a belongs_to assignment
...ons here end end but when I tried to assign parent, parent_id was not changed. Can someone help? class Company < ActiveRecord::Base has_many :children, :class_name => ''Company'', :foreign_key => ''parent_id'', :after_add => :after_add_child, :before_remove => :before_remove_child belongs_to :parent, :class_name => ''Company'', :foreign_key => ''parent_id'' # something similar to :after_add above? end -- Endy -- Posted via http://www.ruby-forum.com/.
2007 Sep 07
5
enforce mutual exclusivity
Hi, First post, please be gentle! I couldn''t find any mention of this already I''m using ActiveRecord and I want to enforce mutual exclusivity on a has_and_belongs_to_many. A concrete example: I have a User which can have one or more Roles (student, tutor, headmaster, administrator etc). However if a user is a student they cannot hold any other role. I was hoping to find