Raised by {ActiveRecord::Base#save!}[rdoc-ref:Persistence#save!] and {ActiveRecord::Base.create!}[rdoc-ref:Persistence::ClassMethods#create!] methods when a record is invalid and cannot be saved.
  
    
      Register or 
      log in
      to add new notes.
  
  
  
  
      
     tadman -  
    June  3, 2009
 tadman -  
    June  3, 2009 
    
  
  
  
       
  
  
  
           tadman -  
    June  3, 2009
 tadman -  
    June  3, 2009 
    
  
    
    9 thanks
     
  
  
  ActiveRecord::RecordNotSaved can be triggered by accidental false return values in callbacks
You may have this exception raised if any of the defined callbacks such as ActiveRecord::Base#before_save or ActiveRecord::Base#before_create return false.
This can happen accidentally. For example:
class MyModel < ActiveRecord::Base before_save :assign_default_foo protected def assign_default_foo self.foo = false end end
Since assign_default_foo leaves a false value on the stack, the model will not be saved. A way around this is to simply leave nil or an empty return instead:
class MyModel < ActiveRecord::Base before_save :assign_default_foo protected def assign_default_foo self.foo = false nil end end

 RSpec
RSpec Ruby on Rails
Ruby on Rails Ruby
Ruby 
   
   = private
 = private = protected
 = protected
     
    