Another technique which may be overkill for what you need is doing something like this…
Say you have a very simple user signup but, after signup they have to fill in a more extensive user profile which has many more fields. I’ve solved this by doing:
class User < ActiveRecord::Base
validates_presence_of :login, :email
validates_presence_of :password, :unless => :password_set
validates_presence_of :password_confirm, :unless => :password_set
validates_length_of :password, :within => 4…40, :unless => :password_set
validates_confirmation_of :password, :unless => :password_set
validates_length_of :login, :within => 3…40
validates_length_of :email, :within => 3…100
validates_uniqueness_of :login, :email, :case_sensitive => false
validates_as_email :email
end
This handles the User Form validations
class UserForm < User
validates_presence_of :first_name
validates_presence_of :last_name
end
When doing things that require first, last name just use the UserForm object instead.