Virginian
2008-May-15 18:23 UTC
partial_updates feature in rails 2.1, failing to save because of validate_presence _of on other attributes in the table
I am trying to use the new partial_updates feature in rails 2.1, http://dev.rubyonrails.org/changeset/9157 but it is failing by trying to use all validations in the model instead of just the changed attributes. The model works as I can successfully .save(false) but if I try a regular .save I get an error saying that it could not save because of validations problems. I want to use this to get around the challenges of saving a part of a wide table without resorting to the validation_scenarios plugin. Any ideas on how I can fix this? Black-Mac:turbocis89 Charles$ script/console Loading development environment (Rails 2.0.991)>> Spec.partial_updates=> true>> User.partial_updates=> true>> @user = User.find_by_screen_name(''vince888'')=> #<User id: 1, screen_name: "vince888", password: "vince888", email: "vince-wop0JeY5JKhWk0Htik3J/w@public.gmane.org", created_at: "2008-05-15 12:35:12", updated_at: "2008-05-15 13:03:38", authorization_token: nil>>> @user.spec.city_of_birth=> "Wichita">> @user.spec.city_of_birth = ''Charleston''=> "Charleston">> @user.spec.changes=> {"city_of_birth"=>["Wichita", "Charleston"]}>> @user.spec.save=> false ### in the application this is failing because of other unrelated attributes not passing validations.>> @user.spec.save(false)=> true>> >> @user.spec.changes=> {}>> >> @user.spec.city_of_birth=> "Charleston">>--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Maybe Matching Threads
- undefined method `partial_updates='
- ActiveRecord in Rails 2.1.0 misbehaving for Aggregate Attr.
- Rails 2.1 and default setting of Partial updates
- Isn't there any performance issue when saving serialized attributes every time?
- Putting it all in one place with Schemas