Skip to content

Instantly share code, notes, and snippets.

@matthooks
Created December 1, 2008 04:21
Show Gist options
  • Save matthooks/30618 to your computer and use it in GitHub Desktop.
Save matthooks/30618 to your computer and use it in GitHub Desktop.
###
if options[:validate_password_field]
validates_length_of options[:password_field], {:minimum => 4, :if => "validate_#{options[:password_field]}?".to_sym}.merge(options[:password_field_validates_length_of_options])
validates_confirmation_of options[:password_field], options[:password_field_validates_confirmation_of_options].merge(:if => "#{options[:password_salt_field]}_changed?".to_sym)
validates_presence_of "#{options[:password_field]}_confirmation", :if => "#{options[:password_salt_field]}_changed?".to_sym
end
###
class_eval <<-"end eval", __FILE__, __LINE__
# etc
def validate_#{options[:password_field]}?
self.#{options[:crypted_password_field]}.blank?
end
# etc
end_eval
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment