Topic: Skip validation not working
For a rec sports league app, I have a Player model set up with some typical validation on signup:
validates_length_of :login, :within => 3..40
validates_length_of :password, :within => 5..40
validates_presence_of :login, :email, :password, :password_confirmation, :salt
validates_uniqueness_of :login, :email, :on => :create
This works well during initial signup and when a player edits his/her profile. But I also have a page to register for each season, which doesn't include all the fields (namely password), because a player already will have logged in before getting to this page.
Problem is, by NOT sending the password attribute and trying to do a save, I get validation errors (password missing, not long enough, no confirmation, etc.) even when I try a @player.save(false) ... or @player.save_with_validation(false).
Here's the still-in-progress def, which still brings up validation errors:
@player = Player.find(session[:player][:id])
flash[:message] = "Registration successful"
redirect_to :action => "pay"
flash[:warning] = "Registration unsuccessful"
I suppose I could include password and confirmation as hidden variables, but that's an ugly workaround that I'm sure is unnecessary.