15 May 20:20
partial_updates feature in rails 2.1, failing to save because of validate_presence _of on other attributes in the table
From: Virginian <CharlesEHarvey@...>
Subject: partial_updates feature in rails 2.1, failing to save because of validate_presence _of on other attributes in the table
Newsgroups: gmane.comp.lang.ruby.rails
Date: 2008-05-15 18:23:02 GMT
Subject: partial_updates feature in rails 2.1, failing to save because of validate_presence _of on other attributes in the table
Newsgroups: gmane.comp.lang.ruby.rails
Date: 2008-05-15 18:23:02 GMT
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@...", 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@... To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@... For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
RSS Feed